Package org.apache.lucene.index
Class IndexUpgrader
- java.lang.Object
-
- org.apache.lucene.index.IndexUpgrader
-
public final class IndexUpgrader extends java.lang.Object
This is an easy-to-use tool that upgrades all segments of an index from previous Lucene versions to the current segment file format. It can be used from command line:java -cp lucene-core.jar org.apache.lucene.index.IndexUpgrader [-delete-prior-commits] [-verbose] indexDir
Alternatively this class can be instantiated andupgrade()
invoked. It usesUpgradeIndexMergePolicy
and triggers the upgrade via an forceMerge request toIndexWriter
.This tool keeps only the last commit in an index; for this reason, if the incoming index has more than one commit, the tool refuses to run by default. Specify
-delete-prior-commits
to override this, allowing the tool to delete all but the last commit. From Java code this can be enabled by passingtrue
toIndexUpgrader(Directory,InfoStream,boolean)
.Warning: This tool may reorder documents if the index was partially upgraded before execution (e.g., documents were added). If your application relies on "monotonicity" of doc IDs (which means that the order in which the documents were added to the index is preserved), do a full forceMerge instead. The
MergePolicy
set byIndexWriterConfig
may also reorder documents.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
deletePriorCommits
private Directory
dir
private IndexWriterConfig
iwc
private static java.lang.String
LOG_PREFIX
-
Constructor Summary
Constructors Constructor Description IndexUpgrader(Directory dir)
Creates index upgrader on the given directory, using anIndexWriter
using the givenmatchVersion
.IndexUpgrader(Directory dir, IndexWriterConfig iwc, boolean deletePriorCommits)
Creates index upgrader on the given directory, using anIndexWriter
using the given config.IndexUpgrader(Directory dir, InfoStream infoStream, boolean deletePriorCommits)
Creates index upgrader on the given directory, using anIndexWriter
using the givenmatchVersion
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
main(java.lang.String[] args)
Main method to run {code IndexUpgrader} from the command-line.(package private) static IndexUpgrader
parseArgs(java.lang.String[] args)
Parse arguments.private static void
printUsage()
void
upgrade()
Perform the upgrade.
-
-
-
Field Detail
-
LOG_PREFIX
private static final java.lang.String LOG_PREFIX
- See Also:
- Constant Field Values
-
dir
private final Directory dir
-
iwc
private final IndexWriterConfig iwc
-
deletePriorCommits
private final boolean deletePriorCommits
-
-
Constructor Detail
-
IndexUpgrader
public IndexUpgrader(Directory dir)
Creates index upgrader on the given directory, using anIndexWriter
using the givenmatchVersion
. The tool refuses to upgrade indexes with multiple commit points.
-
IndexUpgrader
public IndexUpgrader(Directory dir, InfoStream infoStream, boolean deletePriorCommits)
Creates index upgrader on the given directory, using anIndexWriter
using the givenmatchVersion
. You have the possibility to upgrade indexes with multiple commit points by removing all older ones. IfinfoStream
is notnull
, all logging output will be sent to this stream.
-
IndexUpgrader
public IndexUpgrader(Directory dir, IndexWriterConfig iwc, boolean deletePriorCommits)
Creates index upgrader on the given directory, using anIndexWriter
using the given config. You have the possibility to upgrade indexes with multiple commit points by removing all older ones.
-
-
Method Detail
-
printUsage
private static void printUsage()
-
main
public static void main(java.lang.String[] args) throws java.io.IOException
Main method to run {code IndexUpgrader} from the command-line.- Throws:
java.io.IOException
-
parseArgs
static IndexUpgrader parseArgs(java.lang.String[] args) throws java.io.IOException
Parse arguments.- Throws:
java.io.IOException
-
upgrade
public void upgrade() throws java.io.IOException
Perform the upgrade.- Throws:
java.io.IOException
-
-