Issue with ordered intervals queries

Hello,
we use elasticsearch 7.2.0 (but the problem also exists in 7.4.2) and we have some problems with intervals queries.

To reproduce our problem, create a simple index :

PUT intervals_tests
{
  "mappings": {
    "dynamic": "strict",
    "properties": {
      "object": { "type": "text" }
    }
  }
}

Add that simple document :

{
    "object": "issue with intervals queries from search engine. So it's a big issue for us as we need to do ordered searches. Thank you to help us concerning that issue"
}

Execute that simple intervals query :

{
    "query": {
        "intervals": {
            "object": {
                "match": {
                    "query": "issue engine ordered",
                    "max_gaps": 1,
                    "ordered": true
                }
            }
        }
    },
    "highlight": {
        "type": "unified",
        "fields": {
            "object": {}
        }
    }
}

The document will match... but it would not...

If you execute the same query but with "ordered": false, the document will not match !

This error happen because the document contains 3 times the word "issue" (of course I don't know why...). If you delete any of the "issue" words, all is working fine.

To work around that, I use query like that :

{
    "query": {
        "intervals": {
            "object": {
                "match": {
                    "query": "issue engine ordered",
                    "max_gaps": 1,
                    "ordered": true,
                    "filter": {
                        "contained_by": {
                            "match": {
                                "query": "issue engine ordered",
                                "max_gaps": 1,
                                "ordered": false
                            }
                        }
                    }
                }
            }
        }
    },
    "explain": true,
    "highlight": {
        "type": "unified",
        "fields": {
            "object": {}
        }
    }
}

Am I doing something wrong ?
Thank you for your help
Bertrand

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