Questions about Enforcing ElasticSearch Mapping


(Dadepo) #1

Ok, so I created a mapping...say we call it "my_mapping" that specifies two properties: "property1, property2"...

So I then attempted to index a document with the following format:

{
"newproperty5" : "Value"
}

With the expectation that the indexing operation will fail with ElasticSearch telling me the structure of the document is wrong...but to my utmost surprise the document was still indexed! And when I checked the mapping definition for "my_mapping" I found out that ElasticSearch has silently updated my mapping definition to now include the property "newproperty5"!

Can someone explain how this makes sense? What is the essence of creating a type when it can't be strictly enforced!


(Jelmer Kuperus) #2

I believe you can disable dynamic mapping. see :

https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-object-type.html


(Dadepo) #3

@jelmer and I also found this https://www.elastic.co/guide/en/elasticsearch/guide/current/dynamic-mapping.html

Thanks!


(system) #4