Alok Chaudhary
Alok Chaudhary

Reputation: 3511

Scoring in Solr

Calculating the solr score based upon the percentage of the two strings matched.

For ex:If I searched for ABDUL then the results which are similar to this search string should be higher in score and so on.

The sample output from my application is: Output Names score Abdel Aziz RANTISI 2.218595
Abdul Hussein ABBAS 2.218595
Abdul Kader Ibrahim MOHAMED 2.218595

I am not able to figure out how this score is assigned to these results and if i need to change the score then how can i modify this score. I have gone through this link http://lucene.apache.org/core/3_6_0/scoring.html

Upvotes: 0

Views: 767

Answers (1)

MatsLindh
MatsLindh

Reputation: 52902

I don't think you should consider the actual score, but rather how scoring affects the result presented.

Solr does, by default, exact matching of terms (since that is what an index does best). Usually you work around this by converting your data both on indexing and on querying, such as for phonetic search - where you index the phonetic version of the field as well as the normal field, and then query using both the regular text and the converted phonetic version of the text. Most useful, non-exact hits are usually produced using a phonetic search, where the phonetic field is scored lower than the exact field. Remember to use a phonetic algorithm that is suitable for the type of content you're indexing (names / general text / etc) and for the language you're indexing.

You can however perform a fuzzy search as well, where you can adjust the similarity factor that determines a hit by using term~[0-1] (if you leave out the value between 0 and 1, 0.5 is used). This might very well be good enough for what you need, and you can tweak the value to allow the kind of fuzziness needed for your application.

You can also use the SpellChecker component to get terms that are closest to what the query consisted of, using different methods of calculating "closeness" (as "percentage similar" is rather open for interpretation), such as levenshtein.

Upvotes: 1

Related Questions