# Updating a field in all documents of an Index

**URL:** <https://discuss.elastic.co/t/updating-a-field-in-all-documents-of-an-index/92544>\
**Category:** Elasticsearch\
**Created:** [July 10, 2017, 10:55pm UTC](https://discuss.elastic.co/t/updating-a-field-in-all-documents-of-an-index/92544 "2017-07-10T22:55:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![g\_dev](https://avatars.discourse-cdn.com/v4/letter/g/91b2a8/32.png) [@g\_dev](https://discuss.elastic.co/u/g_dev)\
**Post date:** [July 10, 2017, 10:55pm UTC](https://discuss.elastic.co/t/updating-a-field-in-all-documents-of-an-index/92544/1 "2017-07-10T22:55:29Z")

</div>

How can I update a field of all documents of an index with one CURL?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 11, 2017, 8:32am UTC](https://discuss.elastic.co/t/updating-a-field-in-all-documents-of-an-index/92544/2 "2017-07-11T08:32:33Z")

</div>

Depending on the complexity of the logic for updating the field, you might consider using the [update by query API](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/docs-update-by-query.html) or the [reindex API](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/docs-reindex.html), possibly with a script or ingest pipeline.

---

<div class="post-metadata">

**Author:** ![g\_dev](https://avatars.discourse-cdn.com/v4/letter/g/91b2a8/32.png) [@g\_dev](https://discuss.elastic.co/u/g_dev)\
**Post date:** [July 11, 2017, 1:59pm UTC](https://discuss.elastic.co/t/updating-a-field-in-all-documents-of-an-index/92544/3 "2017-07-11T13:59:29Z")

</div>

Thanks, Christian, update by query works for me.  
The simplest usage of just performs an update on every document in the index without changing the source. This is useful to pick up a new property or some other online mapping change. Here is the API:  
curl -XPOST 'localhost:9200/twitter/\_update\_by\_query?conflicts=proceed&pretty'  
[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:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 8, 2017, 1:59pm UTC](https://discuss.elastic.co/t/updating-a-field-in-all-documents-of-an-index/92544/4 "2017-08-08T13:59:40Z")

</div>

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