# Type mapping cannot be changed in either direction

**URL:** <https://discuss.elastic.co/t/type-mapping-cannot-be-changed-in-either-direction/230629>\
**Category:** Elasticsearch\
**Created:** [April 30, 2020, 7:52pm UTC](https://discuss.elastic.co/t/type-mapping-cannot-be-changed-in-either-direction/230629 "2020-04-30T19:52:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexfritz](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@alexfritz](https://discuss.elastic.co/u/alexfritz)\
**Post date:** [April 30, 2020, 7:52pm UTC](https://discuss.elastic.co/t/type-mapping-cannot-be-changed-in-either-direction/230629/1 "2020-04-30T19:52:48Z")

</div>

Hi

I got a really strange behavior on one of our Elasticsearch instances running 6.x regarding the 'mapper cannot be changed' error.  
We are using strict mapping on template level and we usually don't have data type changes for the fields. But somehow it has happened, that for some fields the mapping has changed. So now, we have this weird problem that we cannot change the mapping at all or even extend the existing mapping by more fields.

This is the first error message:  
"type":"illegal\_argument\_exception","reason":"mapper [field\_amount] cannot be changed from type [float] to [integer]"

Seems fine. Ok, let's change the type back to float:  
"type":"illegal\_argument\_exception","reason":"mapper [field\_amount] cannot be changed from type [integer] to [float]"

😐

This is bad. How can I solve this problem, so that I'll be able to change the mapping of the template to add more fields?

Thanks  
Alex

---

<div class="post-metadata">

**Author:** ![xeraa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xeraa/32/48181_2.png) [@xeraa](https://discuss.elastic.co/u/xeraa)\
**Post date:** [May 3, 2020, 4:47pm UTC](https://discuss.elastic.co/t/type-mapping-cannot-be-changed-in-either-direction/230629/2 "2020-05-03T16:47:36Z")

</div>

Lucene cannot change the datatype of a field once it has been created. The only way to change from integer to float or the other way around is through a reindex.

Though adding new fields (with a field name that doesn't yet exist) is possible.

---

<div class="post-metadata">

**Author:** ![alexfritz](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@alexfritz](https://discuss.elastic.co/u/alexfritz)\
**Post date:** [May 3, 2020, 7:38pm UTC](https://discuss.elastic.co/t/type-mapping-cannot-be-changed-in-either-direction/230629/3 "2020-05-03T19:38:31Z")

</div>

But how is it possible that there are both data types (integer and float) existing for the same field?

---

<div class="post-metadata">

**Author:** ![xeraa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xeraa/32/48181_2.png) [@xeraa](https://discuss.elastic.co/u/xeraa)\
**Post date:** [May 4, 2020, 8:22am UTC](https://discuss.elastic.co/t/type-mapping-cannot-be-changed-in-either-direction/230629/4 "2020-05-04T08:22:02Z")

</div>

That's not possible. What is the output of `GET <index-name>/_mapping` (probably limited to the relevant section)?

---

<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:** [June 1, 2020, 8:22am UTC](https://discuss.elastic.co/t/type-mapping-cannot-be-changed-in-either-direction/230629/5 "2020-06-01T08:22:12Z")

</div>

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