繁体   English   中英

部分更新弹性搜索NEST 2.x.

[英]Partial update elastic search NEST 2.x

如何在使用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我做错了什么?

使用具有要更新的属性的匿名对象或其他类。 试试这段代码:

var updateResponse = es.Current.Update<MyDocument, object>(1, descriptor => descriptor
            .Doc(new { name = "new name" }));

暂无
暂无

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

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