# How is the addition of a new field to a document handled by ElasticSearch?

**URL:** <https://discuss.elastic.co/t/how-is-the-addition-of-a-new-field-to-a-document-handled-by-elasticsearch/5617>\
**Category:** Elasticsearch\
**Created:** [October 17, 2011, 7:12pm UTC](https://discuss.elastic.co/t/how-is-the-addition-of-a-new-field-to-a-document-handled-by-elasticsearch/5617 "2011-10-17T19:12:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pulkitsinghal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pulkitsinghal/32/802_2.png) [@pulkitsinghal](https://discuss.elastic.co/u/pulkitsinghal)\
**Post date:** [October 17, 2011, 7:12pm UTC](https://discuss.elastic.co/t/how-is-the-addition-of-a-new-field-to-a-document-handled-by-elasticsearch/5617/1 "2011-10-17T19:12:03Z")

</div>

Feel free to correct me if the basics are off in some parts of this  
question:

Given that a JSON document like this is indexed by ES:  
[  
{  
name:"watch",  
type:"rolex"  
},  
{  
name:"apple",  
type:"fruit"  
}  
]

Q1) What happens when a new field is added to new data and needs to be  
indexed?  
For example:  
[  
{  
name:"hoola-hoop",  
type:"toy"  
store:"toys-r-us"  
}  
]  
Is this data still stored in the same index?

Q2) What happens if the newly added field is something that ES founds  
out about through a CouchDB stream? Like the Rolex watch having a  
newly added {store:"watches-r-us"} field, then is the existing index  
entry deleted and re-added in the same index?

---

<div class="post-metadata">

**Author:** ![Karussell1](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Karussell1](https://discuss.elastic.co/u/Karussell1)\
**Post date:** [October 17, 2011, 8:40pm UTC](https://discuss.elastic.co/t/how-is-the-addition-of-a-new-field-to-a-document-handled-by-elasticsearch/5617/2 "2011-10-17T20:40:35Z")

</div>

if the entry has the same id it gets updated. otherwise if you use  
auto id creation you'll have duplicate entries in the index

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 17, 2011, 11:53pm UTC](https://discuss.elastic.co/t/how-is-the-addition-of-a-new-field-to-a-document-handled-by-elasticsearch/5617/3 "2011-10-17T23:53:55Z")

</div>

Also, new field are automatically mapped and added, with mapping  
automatically (or with dynamic templates) automatically set for them.

On Mon, Oct 17, 2011 at 10:40 PM, Karussell [tableyourtime@googlemail.com](mailto:tableyourtime@googlemail.com)wrote:

> if the entry has the same id it gets updated. otherwise if you use  
> auto id creation you'll have duplicate entries in the index

---

<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:** [July 6, 2017, 3:51am UTC](https://discuss.elastic.co/t/how-is-the-addition-of-a-new-field-to-a-document-handled-by-elasticsearch/5617/4 "2017-07-06T03:51:42Z")

</div>


