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


(pulkitsinghal) #1

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?


(Karussell) #2

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


(Shay Banon) #3

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.comwrote:

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


(system) #4