blob: 740ee333fc88736b15e70b6f8796972d4cef255e [file] [log] [blame]
= Merging Indexes
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
If you need to combine indexes from two different projects or from multiple servers previously used in a distributed configuration, you can use either the IndexMergeTool included in `lucene-misc` or the `CoreAdminHandler`.
To merge indexes, they must meet these requirements:
* The two indexes must be compatible: their schemas should include the same fields and they should analyze fields the same way.
* The indexes must not include duplicate data.
Optimally, the two indexes should be built using the same schema.
== Using IndexMergeTool
To merge the indexes, do the following:
. Make sure that both indexes you want to merge are closed.
. Issue this command:
+
[source,bash]
----
java -cp $SOLR/server/solr-webapp/webapp/WEB-INF/lib/lucene-core-VERSION.jar:$SOLR/server/solr-webapp/webapp/WEB-INF/lib/lucene-misc-VERSION.jar org/apache/lucene/misc/IndexMergeTool /path/to/newindex /path/to/old/index1 /path/to/old/index2
----
+
This will create a new index at `/path/to/newindex` that contains both index1 and index2.
. Copy this new directory to the location of your application's Solr index (move the old one aside first, of course) and start Solr.
== Using CoreAdmin
The `MERGEINDEXES` command of the <<coreadmin-api.adoc#coreadmin-mergeindexes,CoreAdminHandler>> can be used to merge indexes into a new core – either from one or more arbitrary `indexDir` directories or by merging from one or more existing `srcCore` core names.
See the <<coreadmin-api.adoc#coreadmin-mergeindexes,CoreAdminHandler>> section for details.