Query-Dsl

Intervals and more-like-this queries

/ Search, / Query-Dsl

Intervals and more-like-this queries #

Two Elasticsearch-compatible queries landed natively in the engine — no more shape-shifting through match_phrase compositions.

intervals is a rule language over term positions. Say “these two phrases within two positions of each other, but only if neither overlaps this third one”:

POST /my-collection/_search
{
  "query": {
    "intervals": {
      "body": {
        "all_of": {
          "ordered": true,
          "intervals": [
            { "match": { "query": "search engine", "max_gaps": 0, "ordered": true } },
            { "match": { "query": "ranking", "max_gaps": 2 } }
          ],
          "filter": { "not_overlapping": { "match": { "query": "deprecated" } } }
        }
      }
    }
  }
}

Eight rule shapes (match, all_of, any_of, prefix, wildcard, fuzzy, regexp, range) and eight positional filter predicates (containing, before, not_overlapping, …) compose into one tree. Unsupported knobs are rejected with named errors instead of silently ignored — ask for a script filter and you will be told no.

...