Elasticsearch , Max length of mapping type long

That’s due to a rounding issue for IEEE-754 double-precision floating point values.

Whole values up until 53 bits can be represented safely, however, 10160815114820887 is 54 bits long (100100000110010011010100011111100011000001110100010111)

The real number you have indexed was indeed 10160815114820887, but due to the above-mentioned rounding issues, it was indexed and shows as 10160815114820888

You can try the following in your browser’s Javascript console:

> var num = 10160815114820887;      <--- assign value
< undefined
> num                               <--- display value
< 10160815114820888

You can also try a quick test in your ES:

# create doc with 10160815114820887
POST test/test/1
{ "number": 10160815114820887 }

# get doc 1
GET test/test/1
# result
{ "number": 10160815114820888 }

As you can see, the number you have indexed (10160815114820887) shows up as 10160815114820888, and can be found as 10160815114820887 because it also gets rounded to 10160815114820888 at search time.

Leave a Comment