What I want to achieve:
document: "one two three four"
search strings:
- "one four" (must match)
- "four one" (must not match)
What I've learned this far:
For order to be accounted for, the span_near
query should be used, but this assumes that the terms are already analyzed by the client (all terms must be supplied separately).
To have the search string analyzed, the phrase_match
query should be used, but it does not take order into account.
It's likely a script should be used (thanks @ChintanShah25), but it seems impossible to analyse the input string inside the script.
How to achieve both analysis and order requirement?