Long value last 3 digits always gets 000

I created an index using the below endpoint:

    PUT test/doc/1
{
  "id":1,
  "test_long": 2305843036566024123
}

Then when I try to get the same document using:

GET test/doc/1

The result I get is:

{
  "_index": "test",
  "_type": "doc",
  "_id": "1",
  "_version": 11,
  "found": true,
  "_source": {
    "id": 1,
    "test_long": 2305843036566024000
  }
} 

The issue is that I persisted 2305843036566024123 but what I get back is 2305843036566024000 so I lose the last 3 digits.

So what is the reason behind this and how can I fix the same?

Hi,

You are not losing the last digits, if you do a curl request as an example:

curl -XGET localhost:9200/test/doc/1 

Also you can try:

GET test/_search
{
  "query": {
    "match": {
      "test_long": 2305843036566024123
    }
  }
}

You can see the value is there and complete. You did not lose anything. This is a problem that is happening when displaying the value.

1 Like

Thanks, @tamara . It shows the correct value in the curl request. It is just due to the limitation of JavaScript that it is rounding off the last 3 digits.

1 Like

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