'type': 'illegal_argument_exception', 'reason': 'mapper [sum] cannot be changed from type [long] to [float]

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!

@honzakral @Honza_Kral :stuck_out_tongue:

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

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

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