Could not dynamically add mapping for field [stats.something.else]. Existing mapping for [stats.something] must be of type object but found [long]

The problem seems to be that we have both a field called stats.something and another field called stats.something.else. I get the above error when I try to submit the second piece of data.

I could replace each dot with an underscore in the keys, but I wonder if there a way to convince ElasticSearch to store both of these fields without changes?

curl --header 'Content-Type: application/json' --request POST --data '{"stats.something": 42}' http://elastic:9200/gabor/doc/
{"_index":"gabor","_type":"doc","_id":"8RKIiHgBRItxhQVCgLCo","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":1,"_primary_term":1}


curl --header 'Content-Type: application/json' --request POST --data '{"stats.something.else": 42}' http://elastic:9200/gabor/doc/
{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Could not dynamically add mapping for field [stats.something.else]. Existing mapping for [stats.something] must be of type object but found [long]."}],"type":"mapper_parsing_exception","reason":"Could not dynamically add mapping for field [stats.something.else]. Existing mapping for [stats.something] must be of type object but found [long]."},"status":400}

If you don't want to be able to index or search for those fields, I think you can use: enabled | Elasticsearch Reference [7.12] | Elastic but I'm unsure it will work for stats.something. You can probably apply this to stats though.

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