Elasticsearch在Elasticsearch 2.3.0中发布了新的Reindex API,当前版本的NEST(2.1.1)是否已使用此api?如果没有,有计划这样做吗?
我知道当前版本有一个reindex方法,但是它迫使您创建新索引。对于我的用例,索引已经存在。
任何反馈/见解将不胜感激。谢谢!
最佳答案
最好在github issues for NEST上问这种问题,因为项目的提交者将能够最好地回答:)
Elasticsearch 2.3.0中提供了A commit went in on 6 April to map the new Reindex API以及其他功能,例如Task Management API和Update By Query。这进入了NEST 2.3.0
NEST 2.x已经包含一个用于进行重新索引的助手,该助手在幕后使用了scan / scroll并返回了IObservable<IReindexResponse<T>>
,可用于观察进度
public class Document {}
var observable = client.Reindex<Document>("from-index", "to-index", r => r
// settings to use when creating to-index
.CreateIndex(c => c
.Settings(s => s
.NumberOfShards(5)
.NumberOfReplicas(2)
)
)
// query to optionally limit documents re-indexed from from-index to to-index
.Query(q => q.MatchAll())
// the number of documents to reindex in each request.
// NOTE: The number of documents in each request will actually be
// NUMBER * NUMBER OF SHARDS IN from-index
// since reindex uses scan/scroll
.Size(100)
);
var observer = new ReindexObserver<Document>(
onNext: reindexResponse =>
{
// do something with notification. Maybe log total progress
},
onError: exception =>
{
throw exception;
},
completed: () =>
{
// Maybe log completion, refresh the index, etc..
}
);
observable.Subscribe(observer);
看一下ReIndex API tests的一些想法。
新的Reindex API在客户端中名为
client.ReIndexOnServer()
,以将其与现有的可观察实现区分开。关于elasticsearch - 巢-重新编制索引,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36508292/