【问题标题】:Elasticsearch - How to Reindex using NEST 7.1 SDKElasticsearch - 如何使用 NEST 7.1 SDK 重新索引
【发布时间】:2019-10-29 22:05:25
【问题描述】:

我正在将我的 NEST 版本从 6.8 升级到 7.1。由于它是主要版本升级,我正在经历一些重大变化。

其中一项重大更改是使用 Reindex API。在 NEST 6.8 的早期,我曾经像这样重新索引:

var req = new JObject
{
    { "source", new JObject
        {
            { "index", "sourceIndexName" }
        }
    },
    { "dest", new JObject
        {
            { "index", "destIndexName" }
        }
    }
};
var postDataRequest = JsonConvert.SerializeObject(jsonReindexReq, defaultJsonSerializerSettings);
var response = await elasticSearchClient.LowLevel.ReindexAsync<StringResponse>(postDataRequest, null, cancellationToken);

我现在如何使用 NEST 7.1 做到这一点?

我看到新 SDK 中存在 14 种不同风格的 reindex api,但我无法在网上找到任何示例。

【问题讨论】:

    标签: c# elasticsearch nest aws-elasticsearch


    【解决方案1】:

    有几个构造函数,你可以有 cancelToken 或其他一些东西。

    查询应该是:

       var reindexResponse = client.ReindexOnServer(r => r 
                    .Source(sou => sou.Index("sourceindex"))
                    .Destination(des => des.Index("destindex"))
                    .WaitForCompletion(true)
                    );
    

    【讨论】:

      猜你喜欢
      • 2017-12-29
      • 2014-11-12
      • 1970-01-01
      • 2019-11-06
      • 1970-01-01
      • 2018-01-12
      • 2020-09-11
      • 2016-07-30
      • 1970-01-01
      相关资源
      最近更新 更多