# 'type': 'illegal\_argument\_exception', 'reason': 'mapper \[sum\] cannot be changed from type \[long\] to \[float\]

**URL:** <https://discuss.elastic.co/t/type-illegal-argument-exception-reason-mapper-sum-cannot-be-changed-from-type-long-to-float/170944>\
**Category:** Elasticsearch\
**Created:** [March 5, 2019, 3:45pm UTC](https://discuss.elastic.co/t/type-illegal-argument-exception-reason-mapper-sum-cannot-be-changed-from-type-long-to-float/170944 "2019-03-05T15:45:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![revelc33](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/revelc33/32/123408_2.png) [@revelc33](https://discuss.elastic.co/u/revelc33)\
**Post date:** [March 5, 2019, 3:45pm UTC](https://discuss.elastic.co/t/type-illegal-argument-exception-reason-mapper-sum-cannot-be-changed-from-type-long-to-float/170944/1 "2019-03-05T15:45:21Z")

</div>

Hi,  
i am having problems indexing some documents with python elasticsearch helper (bulk) . I index 504 documents and i get 2 with error like described below!

400, 'error': {'type': 'illegal\_argument\_exception', 'reason': 'mapper [sum] cannot be changed from type [long] to [float]'}}}]

The crazy thing it's that the "sum "value is something like 1.64 obtained it from a JSON api response. In 504 documents the values where correctly interpreted as float and in 2 documents are interpreted as [long] . I have same problem with different responses from the api. The field changes randomly and the values are one dot something (2 or 3 decimals ) or cero with 2 decimals. Clearly float numbers.

I know i can solve this issue converting every value of every document. But i want to find another solution because i have a lot of documents types and with many values with the same issue.

From getting the api response i use python-requests.

Can somebody help me on this issue please?

Elasticsearch "6.4.2"  
python (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32

Thanks!

---

<div class="post-metadata">

**Author:** ![revelc33](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/revelc33/32/123408_2.png) [@revelc33](https://discuss.elastic.co/u/revelc33)\
**Post date:** [March 5, 2019, 3:46pm UTC](https://discuss.elastic.co/t/type-illegal-argument-exception-reason-mapper-sum-cannot-be-changed-from-type-long-to-float/170944/2 "2019-03-05T15:46:42Z")

</div>

@honzakral @Honza_Kral😛

---

<div class="post-metadata">

**Author:** ![honzakral](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/honzakral/32/44958_2.png) [@honzakral](https://discuss.elastic.co/u/honzakral)\
**Post date:** [March 5, 2019, 4:48pm UTC](https://discuss.elastic.co/t/type-illegal-argument-exception-reason-mapper-sum-cannot-be-changed-from-type-long-to-float/170944/3 "2019-03-05T16:48:43Z")

</div>

Hi, the proper solution would be to define the index mappings when creating the index, declaring the field as `float`. Relying on dynamic mappings can have drawbacks like the one observed here

---

<div class="post-metadata">

**Author:** ![revelc33](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/revelc33/32/123408_2.png) [@revelc33](https://discuss.elastic.co/u/revelc33)\
**Post date:** [March 6, 2019, 4:33pm UTC](https://discuss.elastic.co/t/type-illegal-argument-exception-reason-mapper-sum-cannot-be-changed-from-type-long-to-float/170944/4 "2019-03-06T16:33:08Z")

</div>

Thanks @honzakral mapping the controversial fields was the solution for me !

---

<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 3, 2019, 4:33pm UTC](https://discuss.elastic.co/t/type-illegal-argument-exception-reason-mapper-sum-cannot-be-changed-from-type-long-to-float/170944/5 "2019-04-03T16:33:17Z")

</div>

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