0

I want to make a query where I need crocodile to be near to luffy or crocodile near to robin. But the query crocodile AND (luffy OR robin) is not exactly what I want because the maximum distance need to be 3, so I tried something like it(the default operator is set to AND):

"crocodile (luffy OR robin)"~3

But it not work. How can I achieve this purpose using these operators? I dont want to use something like:

"crocodile AND luffy "~3 OR "crocodile AND robin "~3

Because It will turn my queries too long.

ES documentations talks about avoid mixing fuzzines with wildcards, but I don't found nothin about proximity with parentheses.

  • Similar to [this question](https://stackoverflow.com/questions/67987989/boolean-query-with-multiple-ors-in-a-proximity-search-using-lucene-syntax). As far as I know you cannot do mix proximity searches with boolean operators in Lucene queries. Your alternative is to use [span queries](https://www.elastic.co/guide/en/elasticsearch/reference/current/span-queries.html) or [interval queries](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-intervals-query.html) which are meant exactly for that use case. – Val Jul 19 '23 at 03:58
  • ty for your support @Val , I'll try it. – Leonardo Furtado Jul 19 '23 at 12:54

0 Answers0