# Adding a field to all documents

**URL:** <https://discuss.elastic.co/t/adding-a-field-to-all-documents/86698>\
**Category:** Elasticsearch\
**Created:** [May 22, 2017, 3:57pm UTC](https://discuss.elastic.co/t/adding-a-field-to-all-documents/86698 "2017-05-22T15:57:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![henrilabarre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/henrilabarre/32/16909_2.png) [@henrilabarre](https://discuss.elastic.co/u/henrilabarre)\
**Post date:** [May 22, 2017, 3:57pm UTC](https://discuss.elastic.co/t/adding-a-field-to-all-documents/86698/1 "2017-05-22T15:57:20Z")

</div>

Hi I have an index of 10 millions documents but I notice that I need a new field for each doc. The question is How can I batch update the all documents where this field doesn't exist?

The idea is to check if the field exist and if not add it to the doc

Thanks for your help

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 25, 2017, 10:04am UTC](https://discuss.elastic.co/t/adding-a-field-to-all-documents/86698/2 "2017-05-25T10:04:13Z")

</div>

[https://www.elastic.co/guide/en/elasticsearch/reference/5.4/docs-update.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/docs-update.html) should do what you want!

---

<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:** [June 22, 2017, 10:04am UTC](https://discuss.elastic.co/t/adding-a-field-to-all-documents/86698/3 "2017-06-22T10:04:40Z")

</div>

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