I know this happening because there is a field whose data type is different from the actual kind of data that is coming. But I have used dynamic mapping wherein I don't specify the mapping and allow the elastic to map itself. The problem that I am facing is, few days back a field called create_date was of date type but now since I do a Json.dump it has become of type string and there is a conflict because of this.
Every day a new index gets created and corresponding new mapping has to get created for it. Then why does this conflict happen? can't we have different mappings for different indices? and how can i resolve this conflict and make sure that the elastic picks up the current datatype and ignores the conflicts
Once a mapping is created it cannot be changed so dynamic mapping won't help you here You have to specify the mappings manually or use index templates to define them implicitly for a set of indices.
Hope this helps,
Honza
But the problem I have is I can't specify the mapping while an index gets created. That is because the content is a dynamic JSON whose fields are not predefined. Kindly suggest me an approach where in I am able to allow dynamic mapping and whenever the data type of a field changes the elastic considers the latest datatype
Elasticsearch cannot change a datatype of an existing field, due to its nature it is impossible.
If you need to control the mappings of newly created indices, without creating them explicitly before indexing, please have a look at index templates - https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html
Ok I get that. But how do I clean up the existing conflicts that have already occured ?
You have to delete the indices and create new ones with proper mappings.
Ok Thank you Honza
Most helpful comment
You have to delete the indices and create new ones with proper mappings.