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

**URL:** <https://discuss.elastic.co/t/could-not-dynamically-add-mapping-for-field-stats-something-else-existing-mapping-for-stats-something-must-be-of-type-object-but-found-long/268919>\
**Category:** Elasticsearch\
**Created:** [March 31, 2021, 2:01pm UTC](https://discuss.elastic.co/t/could-not-dynamically-add-mapping-for-field-stats-something-else-existing-mapping-for-stats-something-must-be-of-type-object-but-found-long/268919 "2021-03-31T14:01:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![szabgab](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/szabgab/32/83232_2.png) [@szabgab](https://discuss.elastic.co/u/szabgab)\
**Post date:** [March 31, 2021, 2:01pm UTC](https://discuss.elastic.co/t/could-not-dynamically-add-mapping-for-field-stats-something-else-existing-mapping-for-stats-something-must-be-of-type-object-but-found-long/268919/1 "2021-03-31T14:01:42Z")

</div>

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?

```auto
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}

```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 31, 2021, 2:48pm UTC](https://discuss.elastic.co/t/could-not-dynamically-add-mapping-for-field-stats-something-else-existing-mapping-for-stats-something-must-be-of-type-object-but-found-long/268919/2 "2021-03-31T14:48:44Z")

</div>

> [@szabgab](#):
>
> 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?

If you don't want to be able to index or search for those fields, I think you can use: [enabled | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/enabled.html) but I'm unsure it will work for `stats.something`. You can probably apply this to `stats` though.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 28, 2021, 2:49pm UTC](https://discuss.elastic.co/t/could-not-dynamically-add-mapping-for-field-stats-something-else-existing-mapping-for-stats-something-must-be-of-type-object-but-found-long/268919/3 "2021-04-28T14:49:12Z")

</div>

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