简体   繁体   English

Elasticsearch - 如何使用 NEST 7.1 SDK 重新索引

[英]Elasticsearch - How to Reindex using NEST 7.1 SDK

I am upgrading my NEST version from 6.8 to 7.1.我正在将我的 NEST 版本从 6.8 升级到 7.1。 Since it is major version upgrade, I am experiencing some breaking changes.由于它是主要版本升级,我正在经历一些重大变化。

One of the breaking change is with Reindex API.一项重大更改是使用 Reindex API。 Earlier in NEST 6.8, I used to reindex like this:在 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);

How would I be able to do it now using NEST 7.1?我现在如何使用 NEST 7.1 来做到这一点?

I see there are 14 different flavors of reindex apis present in the new SDK, but I am not able to find any example online.我看到新的 SDK 中有 14 种不同风格的 reindex api,但我无法在网上找到任何示例。

There is several constructors, you could have cancellationToken or some other stuff.有几个构造函数,你可以有 cancelToken 或其他一些东西。

The query should be:查询应该是:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM