# Elasticsearch update by query using C#

**URL:** <https://discuss.elastic.co/t/elasticsearch-update-by-query-using-c/280874>\
**Category:** Elasticsearch\
**Created:** [August 10, 2021, 5:26am UTC](https://discuss.elastic.co/t/elasticsearch-update-by-query-using-c/280874 "2021-08-10T05:26:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![HYOJIN\_LEE](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hyojin_lee/32/78198_2.png) [@HYOJIN\_LEE](https://discuss.elastic.co/u/HYOJIN_LEE)\
**Post date:** [August 10, 2021, 5:26am UTC](https://discuss.elastic.co/t/elasticsearch-update-by-query-using-c/280874/1 "2021-08-10T05:26:17Z")

</div>

hi, I have a problem.

I want to update only one data in **sub\_info**.  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/a/6a0a071b909102ce466522c4228fe155e687900a.png)

example.. yn\_complete to "N" in cd\_emp = "2021019"  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/5/75a78df536b72cdea1e08ef9c52e6a330038b6a9.png)

But, Currently I get all the **sub\_info** sets,  
change only the part you want, and update the whole to C# as shown below.

```auto
public static bool DoUpdateForSubinfo(string index, string id, List<EmailSubinfo> subinfo)
{
       if (index == string.Empty && id == string.Empty) return false;

       if (_esClient == null) InitializeSettingES();

       var updateResponse = _esClient.Update<object>(id, u => u
              .Index(index)
              .Doc(new
              {
                  sub_info = subinfo
              })
        );

        if (updateResponse.ApiCall.HttpStatusCode == 200) return true;
        else return false;
}

```

When passing **sub\_info** in C#, it it possible to update only the first **yn\_complete** of the list, not the whole?

I'm curious about the c# code for Elastic Search.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 7, 2021, 5:26am UTC](https://discuss.elastic.co/t/elasticsearch-update-by-query-using-c/280874/2 "2021-09-07T05:26:59Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
