0

When using simple_query_string with the prefix operator * and a fuzziness value ~N on the same word the prefix search appears seems to be disabled.

{
  "query": {
    "simple_query_string": {
      "query": "Abcd*~2",
      "fields": ["name"]
    }
  }
}

It's very obvious that prefix gets disabled whenever you set the fuzziness to 0 and the query becomes Abcd*~0 then there is no prefix search and no fuzziness.

This isn't mentioned in the docs so I'm not sure if I'm doing it wrong.

I've tried:

  • swapping the operator order: Abcd~2* -- in _explain this introduces fuzziness variations but omits the prefix operator
  • using parens for precedence: (Abcd*)~2 -- in _explain this uses the prefix but omits the fuzziness operator1
  • duplicating the word: (Abcd* Abcd~2) -- this works, it obviously shows the reunion of both queries instead of the composition of both effects2.

1 I'm assuming that in this case ~2 shouldn't be interpreted as the SLOP operator because there is no phrase (no quotes).

2 I can understand that compositing those effects may generate too many possible variants -- fuzzy adds 50 variants then prefix searches for each of those, that

2
  • 1
    In query string it is mentioned that "Avoid mixing fuzziness with wildcards Mixing fuzzy and wildcard operators is not supported. When mixed, one of the operators is not applied" elastic.co/guide/en/elasticsearch/reference/current/…. I think this will apply to simple_query_string too Commented May 27, 2020 at 9:24
  • It probably shares an underlying implementation. Thank you @jaspreetchahal Can you please write your comment as an answer so I can accept it? Commented May 27, 2020 at 9:33

1 Answer 1

2

As per query-string docs

Mixing fuzzy and wildcard operators is not supported. When mixed, one of the operators is not applied. For example, you can search for app~1 (fuzzy) or app* (wildcard), but searches for app*~1 do not apply the fuzzy operator (~1).

It considers either wildcard or fuzzy whichever is first. For Abcd~2* It is just returning all the documents

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.