# Need help with update operations in elastic search

**URL:** <https://discuss.elastic.co/t/need-help-with-update-operations-in-elastic-search/122972>\
**Category:** Elasticsearch\
**Created:** [March 7, 2018, 9:53pm UTC](https://discuss.elastic.co/t/need-help-with-update-operations-in-elastic-search/122972 "2018-03-07T21:53:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![udit.agg89](https://avatars.discourse-cdn.com/v4/letter/u/ba9def/32.png) [@udit.agg89](https://discuss.elastic.co/u/udit.agg89)\
**Post date:** [March 7, 2018, 9:53pm UTC](https://discuss.elastic.co/t/need-help-with-update-operations-in-elastic-search/122972/1 "2018-03-07T21:53:46Z")

</div>

In the below given use case, I want to update the name field and change its value to “My name is Mathews Fox”

"\_index": "log",  
"\_type": "info log",  
"\_id": "7715ed0b-853e-4d28-b2e3-99156d6dcb3a",  
"\_score": 5.93148,  
"\_source": {  
"Name": "My name is Lucius fox",  
}

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 7, 2018, 10:59pm UTC](https://discuss.elastic.co/t/need-help-with-update-operations-in-elastic-search/122972/2 "2018-03-07T22:59:28Z")

</div>

```
PUT log/info log/7715ed0b-853e-4d28-b2e3-99156d6dcb3a
{
  "Name": "My name is Mathews fox",
}
```

---

<div class="post-metadata">

**Author:** ![udit.agg89](https://avatars.discourse-cdn.com/v4/letter/u/ba9def/32.png) [@udit.agg89](https://discuss.elastic.co/u/udit.agg89)\
**Post date:** [March 7, 2018, 11:16pm UTC](https://discuss.elastic.co/t/need-help-with-update-operations-in-elastic-search/122972/3 "2018-03-07T23:16:52Z")

</div>

Thanks David!  
The problem I have at hand is that I wouldn't be aware of id. I want to search on the substring "Lucius" in the "Name" field and if there is a match, then replace "Lucius" with "Mathews" in the "Name" field.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 7, 2018, 11:39pm UTC](https://discuss.elastic.co/t/need-help-with-update-operations-in-elastic-search/122972/4 "2018-03-07T23:39:36Z")

</div>

So this? [https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html)

---

<div class="post-metadata">

**Author:** ![udit.agg89](https://avatars.discourse-cdn.com/v4/letter/u/ba9def/32.png) [@udit.agg89](https://discuss.elastic.co/u/udit.agg89)\
**Post date:** [March 8, 2018, 12:01am UTC](https://discuss.elastic.co/t/need-help-with-update-operations-in-elastic-search/122972/5 "2018-03-08T00:01:21Z")

</div>

I have already tried this. Using this, I can update the complete value of a field but not the substring. I should be first able to identify whether the field contains a particular substring or not and if it does that replace it with the replacement string.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 8, 2018, 1:21am UTC](https://discuss.elastic.co/t/need-help-with-update-operations-in-elastic-search/122972/6 "2018-03-08T01:21:54Z")

</div>

Share what you tried and we can probably help from there.

A full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) would help. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

---

<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:** [April 5, 2018, 1:22am UTC](https://discuss.elastic.co/t/need-help-with-update-operations-in-elastic-search/122972/7 "2018-04-05T01:22:00Z")

</div>

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