Interval queries filter, not_containing behaving like not overlapping. Intended?

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

      "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.

1 Like

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