The Lucene distribution includes a tool that upgrades an index from the previous Lucene version to the current file format.
The tool can be used from command line, or it can be instantiated and executed in Java.
Indexes can only be upgraded from the previous major release version to the current major release version.
This means that the IndexUpgraderTool in any Solr 8.x release, for example, can only work with indexes from 7.x releases, but cannot work with indexes from Solr 6.x or earlier.
If you are currently using a release two or more major versions older, such as moving from Solr 6x to Solr 8x, you will need to reindex your content.
The IndexUpgraderTool performs a forceMerge (optimize) down to one segment, which may be undesirable.
In a Solr distribution, the Lucene files are located in
./server/solr-webapp/webapp/WEB-INF/lib. You will need to include the
lucene-backwards-codecs-<version>.jar on the classpath when running the tool.
java -cp lucene-core-8.10.0.jar:lucene-backward-codecs-8.10.0.jar org.apache.lucene.index.IndexUpgrader [-delete-prior-commits] [-verbose] /path/to/index
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.
Upgrading large indexes may take a long time. As a rule of thumb, the upgrade processes about 1 GB per minute.
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 document IDs (i.e., the order in which the documents were added to the index is preserved), do a full optimize instead.