Fixing wrong mapping of float as long

Hi,
I am writing daily aggregated data into elasticsearch, creating new index every day.
I don't provide mapping in template, since the fields may change from time to time.
I found out that SUM aggregation I am doing gives me wrong values, while when I look in the raw documents and sum manually, I get the right values.

The bottom line is - in case the first document being indexed has 0 as value, the field will be set as "long", while otherwise it is set as "float".
The values themselves (the ones that are not 0) are saved accurately - (like 1.81) - but when summed - their long value is being used.

I understand there is no easy way to change the map of existing index (or am I wrong ?), but since the value itself is correct, is there a way to force using the proper value when I query and aggregate ?

Thanks,
Shushu

You are right. You can only add fields but not delete or change field types.

The value in the source is correct. The value in the index that aggregations is using is long. The only way to "force" aggregations to use the "correct" value is to load it from the source for every single document that participates in the aggregation. Loading and parsing source of every document is very heavy operation, comparing to reading a value from the index, so in most cases this is not practical.

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