部分更新弹性搜索NEST 2.x [英] Partial update elastic search NEST 2.x

查看:143
本文介绍了部分更新弹性搜索NEST 2.x的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用NEST2部分更新记录?

how can partial update a record in using NEST2?

我正在寻找模拟请求:
POST / erection / shop / 1 / _update
{doc:{new:0}}

I'm looking for an analog request: POST /erection/shop/1/_update {"doc": {"new":"0"}}

不重新创建新记录。不幸的是,我没有在www.elastic.co/guide/en/elasticsearch/client/net-api/current/index.html

without recreating a new record. unfortunately I did not find anything about the updates in 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"
     }));

我运行这段代码,但完全更新了整个文档。

I run this code, but it is fully updated the whole document.

结果 https://gyazo.com/2fdae851bb8bc445f6e8e58abb2f0e3b
我是什么做错了?

result https://gyazo.com/2fdae851bb8bc445f6e8e58abb2f0e3b what am I doing wrong?

推荐答案

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

Use anonymous object or another class with properties that you want update. try this code:

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

这篇关于部分更新弹性搜索NEST 2.x的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆