solr merge collection

     When you need to merge two different projects or multiple servers configured separately, you can either use the IndexMergeTool tool in lucene-misc, or you can use CoreAdminHandler.

      To merge indexes, the following requirements must be met: 1. The two indexes must be compatible: the schema needs to contain the same fields, and the field analysis methods are the same. 2. Must not contain the same data. Preferably both indexes are generated with the same schema.xml file.

1. Using IndexMergeTool

1. Find the lucene-core and lucene-misc JAR packages. It can be obtained by decompressing solr.war (jar xvf solr.war). These two JAR packages should be under /WEB-INF/lib.

2. Copy it to a place where you can find it easily.

3. Ensure that both collections to be merged are closed.

4.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

Create a new index at /path/to/newindex, containing index1 and index2

5. Copy this new folder to your application's solr index (remove the old one first) and start solr.

2. Use CoreAdmin

This method uses CoreAdminHandler to run the MERGEINDEXES command with two parameters, indexDir and srcCore.

indexDir: Used to define the folder where the index data of the cores to be merged are located, and then merge them into a third-party core that already existed before the merge was started. The index must be on the same disk as the Solr host, which makes it cumbersome to use in a distributed environment. After you have the indexDir parameter, you need to call commit in the corresponding core (so that IndexWriter will be closed).

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326059817&siteId=291194637