Dynamic mapping setting not honoured

If I create new index with a mapping definition eg.

{ "mappings": { "dynamic": "false", "properties": { ...} } }

and then send data to it with fields that aren't included in the mapping, they are still created dynamically. If I set dynaminc to "strict" then the data sent is dropped. Having dynamic as false seems to give identical behaviour to having it as true, or undefined.

Am I missing something?

This is with elasticsearch v 7.10.1

Hopefully this could save someone some time.

Turned out this was me misunderstanding that elasticsearch stores the entire object given to it as the _source property of the document. I was mistaken about the mapping changing, with dynamic: false the mapping remains unaltered, elasticsearch only indexes the properties you told it to in the mapping.

So the confusion was that elasticsearch still stores the entire document that you post in to it, not just the data that you defined as indexes in the mapping. Which on reflection some might say is pretty obvious if you understand the basic principles of how elasticsearch works, which I obviously did not.

2 Likes

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