ES "minimum_should_match" query how to transform to vespa query?

157 Views Asked by At

we decide migrate es to vespa ES "minimum_should_match" query how to transform to vespa query ?

eg: es query:

"query_string": {
                       "minimum_should_match": "75%",
                       "fields": [],
                       "query": "may is test"
}"

the above query mean three hits match two at least

I try to transform this query by vespa "or" operator but 75% Can't express

1

There are 1 best solutions below

0
On

Thank you for your interest in Vespa,

It's a rather odd text matching feature as for instance dropping a high significant term just because some other none-significant terms matched is IMHO questionable. For example for the query "what is text ranking", requiring 2/3 terms matching makes it ok to match 'what' and 'is' but the significant part is discarded. I would rather look hard at using weakAnd query operator https://docs.vespa.ai/documentation/using-wand-with-vespa.html

There is no direct replacement but you can drop documents in the first-phase ranking function using the rank-score-drop-limit.

rank-profile odd-ranking {
  first-phase {
    rank-score-drop-limit: -5
    expression: if(matchCount(text)/queryTermCount < 0.75, -10, bm25(text))
  }
}

In this case if the matchCount(text)/queryTermCount is below 0.75 the document is assigned a first-phase rank score of -10 and will be dropped from the result set, if it's larger than 0.75 it uses a bm25 score over the text.

But again, look at weakAnd instead of this is for text matching, it will focus on the significant query terms.