Elasticsearch 在 Elasticsearch 2.3.0 中发布了他们新的 Reindex API,当前版本的 NEST (2.1.1) 是否使用了这个 API?如果没有,是否有计划这样做?我知道当前版本有一个 reindex 方法,但它会强制您创建新索引。对于我的用例,索引已经存在。
任何反馈/见解都将得到极大的应用。谢谢!
Elasticsearch 在 Elasticsearch 2.3.0 中发布了他们新的 Reindex API,当前版本的 NEST (2.1.1) 是否使用了这个 API?如果没有,是否有计划这样做?我知道当前版本有一个 reindex 方法,但它会强制您创建新索引。对于我的用例,索引已经存在。
任何反馈/见解都将得到极大的应用。谢谢!
这种问题最好在NEST 的 github 问题上提出,因为该项目的提交者将能够最好地回答:)
4 月 6 日提交了一份提交,以映射 Elasticsearch 2.3.0 中可用的新 Reindex API,以及其他功能,如任务管理 API和按查询更新。这进入了NEST 2.3.0
NEST 2.x 已经包含一个用于重新索引的帮助器,它在幕后使用扫描/滚动并返回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)
);
ExceptionDispatchInfo e = null;
var waitHandle = new ManualResetEvent(false);
var observer = new ReindexObserver<Document>(
onNext: reindexResponse =>
{
// do something with notification. Maybe log total progress
},
onError: exception =>
{
e = ExceptionDispatchInfo.Capture(exception);
waitHandle.Set();
},
completed: () =>
{
// Maybe log completion, refresh the index, etc..
waitHandle.Set();
}
);
observable.Subscribe(observer);
// wait for the handle to be signalled
waitHandle.Wait();
// throw the exception if one was captured
e?.Throw();
查看ReIndex API 测试以了解一些想法。
新的 Reindex APIclient.ReIndexOnServer()
在客户端中命名,以区别于现有的 observable 实现。