May I ask what you mean by "corrupt"?
When you index a document with
float, even if you only provide two decimal places in the JSON, the internal float may or may not have the same precision. Floats are stored using standard IEEE-754 floating point representation and not all values are able to be explicitly stored. For example, if you try to store the number
12.12 in an IEEE-754 floating point value, internally it is stored as
12.11999988555908203125 because that is the closest arrangement of mantissa and exponent.
This calculator is a convenient way to see how floats are stored: https://www.h-schmidt.net/FloatConverter/IEEE754.html
So that's part of the issue. The other side of the coin is that Elasticsearch aggregations always operate with Doubles, so all values (longs, bytes, shorts, floats, etc) are upconverted to a double. There are technical reasons and historical reasons for this decision, but that's how it is today.
If you only want to see two decimal places of precision, you can use the
format parameter on the aggregation:
Which should give you only two sigfigs after the decimal (I believe, typed that from memory).