Boolean query with minimum_should_match and fuzzy search

Hello,
I am using a boolean query with minimum_should_match and fuzzy_search. Ex. query (302 -> house number, Jarvis -> street, Buffalo -> city):

{
   "query":{
      "bool":{
         "must":[
            {
               "match":{
                  "full.folding":{
                     "query":"302 Jarvis Buffalo",
                     "operator":"OR",
                     "fuzziness":"2",
                     "prefix_length":1,
                     "max_expansions":50,
                     "minimum_should_match":"75%",
                     "fuzzy_transpositions":true,
                     "lenient":false,
                     "zero_terms_query":"NONE",
                     "auto_generate_synonyms_phrase_query":true,
                     "boost":1.0
                  }
               }
            }
         ],
         "should":[
            {
               "match":{
                  "full.folding":{
                     "query":"302 Jarvis Buffalo",
                     "operator":"AND",
                     "fuzziness":"2",
                     "prefix_length":1,
                     "max_expansions":50,
                     "minimum_should_match":"100%",
                     "fuzzy_transpositions":true,
                     "lenient":false,
                     "zero_terms_query":"NONE",
                     "auto_generate_synonyms_phrase_query":true,
                     "boost":2.5
                  }
               }
            }
         ],
         "adjust_pure_negative":true,
         "boost":1.0
      }
   }
}
  1. For the query like "302 Jarvis Buffalo", it returns OK result (house number type)
  2. For the query like "302sss Jarvis Buffalo", it returns OK result (street type)
  3. For the query like "302sss Jarvissss Buffalo", it returns BAD result (nothing, but should return city Buffalo)

I understand that behavior because I have a 75% minimum_should_match and 1 of 3 it is a bad result. When I set minimum_should_match to 1, then OR operator working on each term separately and don't find "Jarvis Buffalo", but find "Jarvis" or "Buffalo".

My question is:
How I can find a workaround with Elasticsearch to return Buffalo as a city type for the third point and still return good results for the first two points?

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