Upgrading an existing Solr index

If you want to upgrade the existing Solr index, you need access to the existing Solr 4 core indices. The indices are located in the configured data directory of each core. If not changed, the index is located under the data subdirectory of each (Solr 4) core (see Set up the Solr home directory).

In all reference examples starting with version 7.7, make sure to use the exact version for your ImageMaster release according to the [T Compatibility Guide].

This process changes the existing index! Therefore, consider backing up the index if possible.

The index upgrade is done by an IndexUpgrader tool included in the Lucene distribution. This is a Java tool and it can be used from command line. Details can be found in [Solr IdxUpgrader].

The IndexUpgrader tool can only upgrade from the previous major release version to the current major release version!

So if you need to upgrade the index from version 4.x to 7.x, several steps (for each core) are needed:

  • upgrade index from 4.x to 5.x

  • upgrade index from 5.x to 6.x

  • upgrade index from 6.x to 7.x

  • upgrade index from 7.x to 8.x

To run the IndexUpgrader, the following libraries are needed:

  • lucene-core-<version>.jar

  • lucene-backwards-codecs-<version>.jar

Due to the above mentioned limitation, these 2 libraries are needed in different versions:

  • lucene-core-5.5.4.jar and lucene-backward-codecs-5.5.4.jar

  • lucene-core-6.6.0.jar and lucene-backward-codecs-6.6.0.jar

  • lucene-core-7.7.y.jar and lucene-backward-codecs-7.7.y.jar

  • lucene-core-8.7.y.jar and lucene-backward-codecs-8.7.y.jar

You can get the libraries from [Lucene Libs].

Before starting the index upgrade, ensure that neither Solr 4 nor the new Solr version is running.

The index upgrade can be started from the command line with the following command:

java -cp lucene-core-<version>.jar:lucene-backward-codecs-<version>.jar org.apache.lucene.index.IndexUpgrader [-delete-prior-commits] [-verbose] /path/to/index

As mentioned above, the index needs to be upgraded several times for each core. In the command line above, the path ”/path/to/index” has to be changed to the index directory of the core you want to upgrade (e.g. <PATH_TO_SOLR_HOME>/master0/data/index). The <version> has to be changed from 5.5.4 to 6.6.0 to 7.7.y to 8.7.y after each successful upgrade.

The provided Solr home examples include a script “upgradeindex.sh” in the tools directory. Using this script can be an alternative to the manual steps above. Note that the script needs to be marked as executable with chmod +x upgradeindex.sh before execution. This script downloads the necessary libraries and runs the IndexUpgrader tool in the correct order for all cores, so only one call is required:

./upgradeindex.sh  [-s] [-t target-ver] <indexdata-root>

In the above call the target-ver is the version you want to upgrade to. In our case this should be “7”. The <indexdata-root> can either be the data directory of one core, or the Solr home directory if you want to upgrade all cores at once.

Be sure to include the “–s” parameter if you don’t want to create a backup of the index or have already done so. If you omit the “–s” parameter, the script will create an index backup in <indexdata-root>/<core>/data/index_backup_<version>.tgz.

After completing the index upgrade, either by calling the IndexUpgrader directly, or by using the upgradeindex.sh script, you must get the Solr cores to use the new index. By default the cores indices are located under the data subdirectory of the cores (see Set up the Solr home directory). Although you can override the location for this directory in the file “solcore.properties”, it is recommended using a soft link pointing to the upgraded index instead, or move the upgraded indices to the data directory of the Solr cores.

If you use a soft link, be sure to not delete the upgraded index in the old directory when removing the old Solr version!

Finally, Solr can be started with the updated home directory (according to Starting and stopping Solr).