gray
gray

Reputation: 381

Solr fuzzy match has better score than exact match

I'm doing a fuzzy search in Solr, and in rare cases the exact match has score lower than a fuzzy match. I even found a reason using debugQuery: fuzzy match has matched 3 different words, and exact match matched only one. So the "sum of" 3 matches got better value, than one. Here is part of the "explain".

Is there any way to configure Solr for ranking exact matches higher than fuzzy, even in this case?

P.S. I already using omitTermFreqAndPositions="true" omitNorms="true", but it doesn't help if we have a fuzzy match against different words.

Upvotes: 6

Views: 3580

Answers (2)

Tagar
Tagar

Reputation: 14891

I had a similar problem and solved this by using copyField and doing exact and fuzzy (phonetic in my case) matching on separate fields.

Then used EdisMax's qf field to give higher weight for matches on exact field vs ones on fuzzy matching.

Upvotes: 2

Arun
Arun

Reputation: 1787

You need to do a boolean query of exact match with higher boost with a Boolean OR query of fuzzy query so that exact matches rank higher. Do not worry about double work for solr. It is built for very complex Lucene query trees. Using a combination of queries to get relevancy ranking expected is common practice. If you agree pl. accept my answer.

Upvotes: 6

Related Questions