elasticsearch - 巢-重新编制索引

标签 elasticsearch nest reindex elasticsearch-net

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 APIUpdate 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/

相关文章:

elasticsearch - 筛选器构面返回所有文档的计数,而不是范围

elasticsearch - Elasticsearch 最佳大师数

elasticsearch - 如何在Kibana可视化中使用Elasticsearch嵌套聚合

elasticsearch - 我怎么知道创建索引的Elasticsearch版本?

elasticsearch - Elasticsearch:重新索引时设置字段类型? (可以单独使用_reindex完成)

django - 来自 Haystack 索引的 Unicode 错误

c# - 在嵌套Elasticsearch中使用原始字符串创建查询

c# - ElasticSearch 结合 Terms 和 Match 查询

sorting - 如何将Elasticsearch中的字段值从字符串更改为整数?

elasticsearch - 内部点击无法正常工作ElasticSearch