Shreya Patni
Shreya Patni

Reputation: 62

How to get the version of lucene index in solr

My use case: I am currently on solr 5.5 and upgrading to solr 8.8

For this, I will need to do re-indexing on all machines where solr is installed. I need to do a check on the index version, if the index is made from the old version, then I will run the re-indexing logic, and if it already is the new version, I will skip the re-indexing.

Is there a way to detect the index version?

NOTE: the config files will already be updated to the new version so cannot use tag from solrconfig.xml

Upvotes: 2

Views: 1032

Answers (2)

Mario Trojan
Mario Trojan

Reputation: 21

You can try to use the lucene CheckIndex Tool instead, if you have direct access to the index on the file system.

(Note: You must stop the solr service before executing, else there will be an error.)

java -cp lucene-core-9.3.0.jar:lucene-backward-codecs-9.3.0.jar org.apache.lucene.index.CheckIndex /path/to/index/

Then you should see the index version in the output:

Checking index with threadCount: 12
0.78% total deletions; 290597 documents; 2255 deletions
Segments file=segments_7d numSegments=13 version=8.11.1 id=bmwtml5nan76oxh53jblk3hjg userData={commitCommandVer=1729352676019273728, commitTimeMSec=1649239231128}
1 of 13: name=_2us maxDoc=2
    version=8.11.1
    id=2alyagqpio6wye81jr09czfg9
    codec=Lucene87
    compound=false
    numFiles=18
    size (MB)=0.036
    diagnostics = {java.version=1.8.0_312, java.vm.version=25.312-b07, lucene.version=8.11.1, source=flush, os.arch=amd64, java.runtime.version=1.8.0_312-8u312-b07-0ubuntu1~20.04-b07, os.version=5.4.0-107-generic, java.vendor=Private Build, os=Linux, timestamp=1648810655017}

In this example, i used the tool from version 9 to check an index which was created with version 8. But remember: The libraries you use might only be compatible with the current + the previous lucene index version. So if you use JARs from lucene 9 it will work checking indexes from 9+8, but not from 7.

see also: https://lucene.apache.org/core/9_3_0/core/org/apache/lucene/index/CheckIndex.html

(The usage is similar to the IndexUpgrader described in the documentation:) https://solr.apache.org/guide/solr/latest/deployment-guide/indexupgrader-tool.html

Upvotes: 0

Abhijit Bashetti
Abhijit Bashetti

Reputation: 8658

HTTP GET request to retrive the info :

yoursolrhost:8983/solr/admin/info/system

It would be something like below

http://yoursolrhost:8983/solr/admin/info/system?wt=json

Upvotes: 2

Related Questions