How to prefer match on a longer percentage of the doc over a longer match?

Hi,

I’m using elastic to search terms that were detected in a sentence of free text against an inner DB that was indexed.

I have a problem when my query appears in the DB with some tokens repetition.
For example: I search the term “computer” while the DB includes 2 different documents:

  1. “computer, dell computer”
  2. “computer”
    In this case the first doc (“computer, dell computer”) will be returned because it includes more matches, but the second doc (“computer”) is a more appropriate response.

To clarify, there are cases when the repetition appears also in the query so I can’t just remove duplicates.

I found this solution, but since I’m searching for a free text I want to combine analyzers and fuzziness too.

Is there an option to make sure that the text in the relevant field is contained in my query (taking into account fuzziness) or to change scoring so elastic prefer match on a longer percentage of the doc over a longer match?

Here is my query:
<
GET technology/_search/
{
"explain":"true",
"query": {
"match": {
"term": {
"query": "computer",
"fuzziness":"AUTO",
"max_expansions": 2,
"prefix_length":1,
"fuzzy_transpositions":true
}
}
}
}

Thanks!

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