MergingSolrIndexes

How to Merge Indexes

Sometimes you have more than one solr index and you want to merge them together into a single index. One good way to do this is to use the IndexMergeTool that comes as part of lucene-misc. In order to do this:

  1. Find the lucene jar file that your version of solr is using. You can do this by copying your solr.war file somewhere and unpacking it (jar xvf solr.war). Your lucene jar file should be in WEB-INF/lib. It is probably called something like lucene-core-2007-05-20_00-04-53.jar. Copy it somewhere easy to find.

  2. Download a copy of lucene from [WWW] http://www.apache.org/dyn/closer.cgi/lucene/java/ and unpack it. The file you're interested in is contrib/misc/lucene-misc-VERSION.jar

  3. Make sure both indexes you want to merge are closed.

  4. Issue this command: java -cp /path/to/lucene-core-VERSION.jar:/path/to/lucene-misc-VERSION.jar org/apache/lucene/misc/IndexMergeTool /path/to/newindex /path/to/index1 /path/to/index2

Example

java -cp /tmp/lucene-core-2007-05-20_00-04-53.jar:./lucene-2.2.0/contrib/misc/lucene-misc-2.2.0.jar org/apache/lucene/misc/IndexMergeTool ./newindex ./app1/solr/data/index ./app2/solr/data/index

last edited 2007-11-05 03:47:18 by BessSadler