Searching term with it's position range

Hello, I have a following three document

1. `{field: "one two three"}`
2. `{field: "x one two three"}`
3. `{field: "x y one two three"}`

Question: Can I query term tow with it's position range?
Example: {match: "two", position: [4, 6]} returns 1 & 2 because term "two" position 4 and 6.
#3 is not returned because position of "two" is 8

You can use regex query

  "query": {
    "regexp": {
      "field.keyword": {
        "value": ".{4}.?{2}two.*"

Thank you for your response.
But looks like this performance is not good because I can't use index.

Is it possible using index for this case?

In 7.9 we will be introducing a new field type that index-accelerates regex and wildcard searches like this.

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