Filtering by Long.MAX_VALUE does not return any result

Hi all!

I found an issue when I try to filter documents by range where second parameter is Long.MAX_VALUE.

For example, let's create a schema of the document:

PUT /example

{
    "mappings": {
        "_doc": {
            "properties": {
                "order": {
                    "type": "date",
        			"format": "epoch_millis",
                    "store": true
                }
            }
        }
    }
}

Than add document:

PUT /example/_doc/1

{
    "order": 1568705332742
}

When I execute the query:

POST /example/_search

{
  "query":{
     "bool":{
        "filter":[
           {
              "range":{
                 "order":{
                    "gte":0,
                    "lte":9223372036854775807
                 }
              }
           }
        ]
     }
  }
}

I expect to receive added document, but I receive an empty list.
If I just remove one digit and replace 9223372036854775807 to 922337203685477580 query works.

9223372036854775807 is a 2^63-1. I'm using Java's Long.MAX_VALUE.

According to docs, date is storing as a long internally and long is a signed 64-bit integer with a minimum value of -2^63 and a maximum value of 2^63-1.

Any ideas how to solve it?

Thanks in advance,
Vova

Solution that I found is to use lt except of lte. Just decreasing Long.MAX_VALUE on 1 point does not help.

If you remove the lte completely, does the query work? Each end of the range is optional. I'm just trying to narrow down where the issue might be.

Oh, can you also try placing the value in quotes?

"lte": "9223372036854775807"

Which version of Elasticsearch are you using? If it is before 7.0 (when we switched to using Java Time internally) it is likely https://github.com/elastic/elasticsearch/issues/23436

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