如何在NEST2中更新Elasticsearch文档

我已将代码移植到NEST 2.0和Elasticsearch 2.0

我需要找到一种方法来更新已经存储在ES2中的文档

我正在使用部分对象技术:

        elastic.Update<myDocumentType, myPartialDocumentType>(u => u

.Index(myIndexName)

.Id(id)

.Doc(

new myPartialDocumentType()

{

// set the fields to update here

})

.Refresh());

如何使用NEST2做同样的事情?

回答:

您传递文档ID的方式有些变化。

今天看起来像:

var updateResponse = client.Update<Document, DocumentPartial>(1, descriptor => descriptor

.Doc(new DocumentPartial

{

Title = "new title"

}));

要么

var updateResponse = client.Update<Document, DocumentPartial>(DocumentPath<Document>.Id(1), descriptor => descriptor

.Doc(new DocumentPartial

{

Title = "new title"

}));

希望能帮助到你。

以上是 如何在NEST2中更新Elasticsearch文档 的全部内容, 来源链接: utcz.com/qa/417086.html

回到顶部