# Error with range query inside "not or"

**URL:** https://discuss.elastic.co/t/error-with-range-query-inside-not-or/88766
**Category:** Elasticsearch
**Created:** [June 8, 2017, 10:28pm UTC](https://discuss.elastic.co/t/error-with-range-query-inside-not-or/88766 "2017-06-08T22:28:06Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![a43](https://avatars.discourse-cdn.com/v4/letter/a/e19b73/32.png) [@a43](https://discuss.elastic.co/u/a43)
#### Post date: [June 8, 2017, 10:28pm UTC](https://discuss.elastic.co/t/error-with-range-query-inside-not-or/88766/1 "2017-06-08T22:28:06Z")

</div>

**Elasticsearch version** : 2.4.5

**JVM version** (`java -version`): 1.8.0\_111

**Description of the problem including expected versus actual behavior** :

Using a range query inside an `or` inside a `not` causes an error on 2.4.5, but not on 1.7.1.

**Steps to reproduce** :

This query works fine:

```auto
{
  "filter": {
    "or": [
      { "range": { "value": { "gte": 1, "lt": 3 } } },
      { "range": { "value": { "gte": 5, "lt": 7 } } }
    ]
  }
}

```

but wrapping the `or` in a `not` will cause an error:

```auto
{
  "filter": {
    "not": {
      "or": [
        { "range": { "value": { "gte": 1, "lt": 3 } } },
        { "range": { "value": { "gte": 5, "lt": 7 } } }
      ]
    }
  }
}

```

where the error is a `query_parsing_exception` with message `[or] query does not support [gte]`.

That doesn't seem accurate because it works fine without the `not`.

We are trying to upgrade to 2.x and getting this error there. Our existing version is 1.7.1 where there is no error. (The error occurs on both 2.4.5 and 2.0.0.)

We realize `or` is deprecated, but converting our code to use `should`/`must` syntax is a huge amount of work for various reasons, so we'd prefer any other workarounds or suggestions. Thanks!

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [June 8, 2017, 10:54pm UTC](https://discuss.elastic.co/t/error-with-range-query-inside-not-or/88766/2 "2017-06-08T22:54:33Z")

</div>

Note that `or` has been deprecated as per: [https://www.elastic.co/guide/en/elasticsearch/reference/2.4/query-dsl-or-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.4/query-dsl-or-query.html)  
It has been removed in 5.x series.

Use `should` then.

There are no real workarounds AFAIK.

---

<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: [July 6, 2017, 10:55pm UTC](https://discuss.elastic.co/t/error-with-range-query-inside-not-or/88766/3 "2017-07-06T22:55:15Z")

</div>

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