# Interval queries filter, not\_containing behaving like not overlapping. Intended?

**URL:** <https://discuss.elastic.co/t/interval-queries-filter-not-containing-behaving-like-not-overlapping-intended/263212>\
**Category:** Elasticsearch\
**Created:** [February 4, 2021, 9:01am UTC](https://discuss.elastic.co/t/interval-queries-filter-not-containing-behaving-like-not-overlapping-intended/263212 "2021-02-04T09:01:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaronkiwi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaronkiwi/32/83413_2.png) [@aaronkiwi](https://discuss.elastic.co/u/aaronkiwi)\
**Post date:** [February 4, 2021, 9:01am UTC](https://discuss.elastic.co/t/interval-queries-filter-not-containing-behaving-like-not-overlapping-intended/263212/1 "2021-02-04T09:01:59Z")

</div>

Hello  
I was wondering what the actual difference between the not\_overlapping and not\_containing filters for interval queries are.

From the documentation I would assume that overlapping is when any part of the filter is within the bounds of the interval, while containing would require the entirety of the filter to be within the bound. However when testing this, I find that containing behaves the same as overlapping.

I testing on a simple document like so. (and checked proper tokenization with /\_analyze)

```
{ field: "a b c d e f" }

```

To start off I use this query which does match the document

```json
    {
      "query": {
        "intervals": {
          "field": {
            "match": {
              "query": "a c",
              "max_gaps": 1,
              "ordered": true,
              "filter": {
                "not_containing": {
                  "match": {
                    "query": "d e",
                    "max_gaps": -1,
                    "ordered": true
                  }
                }
              }
            }
          }
        }
      }
    }

```

Changing the "d" in the not containing to a "b", my expectation would be it still matches as the "e" is not contained within the interval "a c" however it does not match.

Is this the intended way for this to behave, if so , are there any options to a proper not containing query? I have tried spans and intervals now.

Through further testing I have also found that the order of the intervals is relevant to whether the query matches. If the filter overlaps (but not contained) with the START of your intervals, the interval will still match. If the filter overlaps (but not contained) with the END of your intervals it will no longer match.

---

<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:** [March 4, 2021, 9:02am UTC](https://discuss.elastic.co/t/interval-queries-filter-not-containing-behaving-like-not-overlapping-intended/263212/2 "2021-03-04T09:02:38Z")

</div>

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