【发布时间】:2016-11-22 13:36:16
【问题描述】:
如何在使用 NEST2 时部分更新记录?
我正在寻找模拟请求: POST /erection/shop/1/_update {"doc": {"new":"0"}}
无需重新创建新记录。不幸的是,我在 www.elastic.co/guide/en/elasticsearch/client/net-api/current/index.html 中没有找到任何有关更新的信息
更新:
var updateResponse = es.Current.Update<MyDocument, MyDocument> (DocumentPath<MyDocument>.Id(2), descriptor => descriptor
.Doc(new MyDocument
{
name = "new name"
}));
我运行这段代码,但它完全更新了整个文档。
结果https://gyazo.com/2fdae851bb8bc445f6e8e58abb2f0e3b 我做错了什么?
【问题讨论】:
-
你会发现一个例子here。
-
感谢答案,但我不明白哪个命名空间有 DocumentPartial 和 DocumentPath。我尝试使用您的代码,但出现错误。
var updateResponse = es.Current.Update<Document, MyDocument>(descriptor => descriptor .Id(1) .Doc(new MyDocument { name = "qwerty" }));我尝试使用此代码,但它更新了所有文档,并将除“名称”之外的所有字段留空 -
您可以发布您的完整示例吗?
标签: c# elasticsearch updates nest