【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 —— 翻译略生硬!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值