Field type for decimal values such as 20.5, 10,3 etc?

Hi,

What is the best field type to use numerical values such as 20.5, 10,3? For some reason I mapped them as half-float long ago but now I sometimes get values such as 20.5123. At the time this was fine as I used Kibana's formatter to just make them look like x.x again but now I want to give some color formatting to my data.

Also, is there any difference between the field type I should use for 20**.5 or 20,**5?

I would use a scaled_float for exact decimal values. A scaled float is just a long internally, that applies a scaling factor to turn it into a decimal for presentation purposes. So you can configure the range of values you care about and keep precision.

The various floats (float, double, half-float, etc) are all true floating-point data types, and you'll see rounding error due to how the floating point math works. Fine for most quantities, but not acceptable for things like currency :slight_smile:

2 Likes

Thanks.

scaled_float and scaling_factor 100 makes x.xx values display correct.

Will updating my template be enough for the new settings to be applied when my index rolls over?

1 Like

Yep, updating the template should allow all new indices to use the new data type. :slight_smile:

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