【Solr迁移文档到新索引】

MIGRATE
假设我们有一个超过十亿个文档的庞大集合,并且我们得到了一个需求,即我们需要用一组特定的文档创建一个单独的索引,或者我们希望根据某些标准将索引分成两部分。将文档迁移到另一个集合使这成为可能。实际上,我们可以在solrcloud中指定源集合和目标集合。根据路由条件,某些文档将从源集合复制到目标集合。我们可以将迁移时间指定为forward.timeout参数,在此期间,所有写请求都将转发到目标集合。当migrate命令运行时,目标集合不能接收任何写入。否则,某些写入可能会丢失。

Let us look at a practical scenario.
We currently have two collections—catcollection and mycollection. Now catcollection contains documents belonging to the categories books, currency, and electronics. Let us move the documents belonging to the category currency from catcollection to mycollection.

The query to get the documents belonging to category currency will include the shard.keys=currency! parameter:

http://solr1:8080/solr/catcollection/select/?q=*:*&rows=15&shard.keys=currency!

Now, let us copy the documents from catcollection to mycollection:

http://solr1:8080/solr/admin/collections?action=MIGRATE&collection=catcollection&split.key=currency!&target.collection=mycollection&forward.timeout=120

Note the following:

  • The action is MIGRATE.
  • The source collection is catcollection.
  • split.key is currency!. All documents that have currency!* as the ID will be moved to mycollection. split.key is identified by the routing parameter that we used earlier. If there is no routing parameter, split.key can be identified by the unique ID of the documents.
  • target.collection refers to the target mycollection.
  • forward.timeout is the timeout specified during which all write requests to catcollection are forwarded to mycollection.

Reference
Migrating documents to another collection
Split all documents of a route key into another collection
Migrate API fails with: Invalid status request: notfoundretried 6times
SolrCloud将文档迁移到另一个集合:MIGRATE —— 翻译略生硬!

你可能感兴趣的:(Solr)