What range of numbers can I represent using scaled_float in Elasticsearch?

Viewed 312

I'm trying to figure out what numbers I can represent using scaled_float.

In the documentation here https://www.elastic.co/guide/en/elasticsearch/reference/master/number.html I first read:

scaled_float

A floating point number that is backed by a long, scaled by a fixed double scaling factor.

So it seems that the size in memory is fixed: a long, that would take 64 bits in memory (the scaling factor being fixed, it's the same for every value and so it doesn't appear in the memory representation of the numbers)

But later on the same page I read, about scaled_float:

High values of scaling_factor improve accuracy but also increase space requirements. This parameter is required.

So it seems, actually the size of a scaled_float is not fixed? Could I represent very, very big numbers and very, very small numbers in the same field if I wanted to? Or are there limits and if so what are those limits?

1 Answers

The "real" size(in memory or disk) is not fixed, depends of the value of scaling_factor. scaling_factor its an additional parameter of scaled_float.

scaling_factor .- Values will be multiplied by this factor at index time and rounded to the closest long value. For instance, a scaled_float with a scaling_factor of 10 would internally store 2.34 as 23 and all search-time operations (queries, aggregations, sorting) will behave as if the document had a value of 2.3. High values of scaling_factor improve accuracy but also increase space requirements. This parameter is required.

scaled_float.- A floating point number that is backed by a long, scaled by a fixed double scaling factor

scaling factor its fixed once its defined.

Related