# Hot to update single doc without id?

**URL:** <https://discuss.elastic.co/t/hot-to-update-single-doc-without-id/154087>\
**Category:** Elasticsearch\
**Created:** [October 26, 2018, 4:20am UTC](https://discuss.elastic.co/t/hot-to-update-single-doc-without-id/154087 "2018-10-26T04:20:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![john4](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@john4](https://discuss.elastic.co/u/john4)\
**Post date:** [October 26, 2018, 4:20am UTC](https://discuss.elastic.co/t/hot-to-update-single-doc-without-id/154087/1 "2018-10-26T04:20:47Z")

</div>

Ok, this might sound strange but i can´t do that simple task: I just want to update one document which has an unique identifier. I don´t know the ID and don´t want to get the id first.

Using '\_update\_by\_query' i get down to the right result, but something like this doesn´t work:

POST index/entity/\_update\_by\_query?conflicts=proceed  
{  
"query": {  
"term": {  
"unique\_identifier": "12345678"  
}  
},  
"terms": { "term": "value" , "another\_term" : "another\_value" }  
}

(I want to update term & another\_term with value and anoter\_value)

Any help appreciated 🙂

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 26, 2018, 12:16pm UTC](https://discuss.elastic.co/t/hot-to-update-single-doc-without-id/154087/2 "2018-10-26T12:16:26Z")

</div>

you need to specify a script to do the actual conversion, see the samples in the docs at [https://www.elastic.co/guide/en/elasticsearch/reference/6.4/docs-update-by-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.4/docs-update-by-query.html)

---

<div class="post-metadata">

**Author:** ![john4](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@john4](https://discuss.elastic.co/u/john4)\
**Post date:** [October 26, 2018, 12:27pm UTC](https://discuss.elastic.co/t/hot-to-update-single-doc-without-id/154087/3 "2018-10-26T12:27:01Z")

</div>

Thanks.. Can you point me in the right direction for a little bit more documentation ? It seems that everybody understands scripting but i have no idea how that works 😉

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [October 26, 2018, 1:41pm UTC](https://discuss.elastic.co/t/hot-to-update-single-doc-without-id/154087/4 "2018-10-26T13:41:08Z")

</div>

There are docs [here](https://www.elastic.co/guide/en/elasticsearch/reference/6.4/modules-scripting-using.html) for scripting. The update by query docs that @spinscale linked you to have a few examples of scripting in the update-by-query context.

---

<div class="post-metadata">

**Author:** ![john4](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@john4](https://discuss.elastic.co/u/john4)\
**Post date:** [October 27, 2018, 3:29pm UTC](https://discuss.elastic.co/t/hot-to-update-single-doc-without-id/154087/5 "2018-10-27T15:29:34Z")

</div>

Tyvm, Sir.

---

<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:** [November 24, 2018, 3:29pm UTC](https://discuss.elastic.co/t/hot-to-update-single-doc-without-id/154087/6 "2018-11-24T15:29:36Z")

</div>

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