# Filtering by Long.MAX\_VALUE does not return any result

**URL:** <https://discuss.elastic.co/t/filtering-by-long-max-value-does-not-return-any-result/199786>\
**Category:** Elasticsearch\
**Created:** [September 17, 2019, 8:22am UTC](https://discuss.elastic.co/t/filtering-by-long-max-value-does-not-return-any-result/199786 "2019-09-17T08:22:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vova\_Marchev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vova_marchev/32/50532_2.png) [@Vova\_Marchev](https://discuss.elastic.co/u/Vova_Marchev)\
**Post date:** [September 17, 2019, 8:22am UTC](https://discuss.elastic.co/t/filtering-by-long-max-value-does-not-return-any-result/199786/1 "2019-09-17T08:22:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Vova\_Marchev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vova_marchev/32/50532_2.png) [@Vova\_Marchev](https://discuss.elastic.co/u/Vova_Marchev)\
**Post date:** [September 19, 2019, 9:39am UTC](https://discuss.elastic.co/t/filtering-by-long-max-value-does-not-return-any-result/199786/2 "2019-09-19T09:39:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [September 25, 2019, 4:21pm UTC](https://discuss.elastic.co/t/filtering-by-long-max-value-does-not-return-any-result/199786/3 "2019-09-25T16:21:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [September 25, 2019, 4:23pm UTC](https://discuss.elastic.co/t/filtering-by-long-max-value-does-not-return-any-result/199786/4 "2019-09-25T16:23:00Z")

</div>

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

```auto
"lte": "9223372036854775807"

```

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [September 25, 2019, 4:44pm UTC](https://discuss.elastic.co/t/filtering-by-long-max-value-does-not-return-any-result/199786/5 "2019-09-25T16:44:17Z")

</div>

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](https://github.com/elastic/elasticsearch/issues/23436)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 23, 2019, 4:44pm UTC](https://discuss.elastic.co/t/filtering-by-long-max-value-does-not-return-any-result/199786/6 "2019-10-23T16:44:20Z")

</div>

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