Building a custom scorer
Now that we know how the default relevance calculation works, let us look at how to create a custom scorer. The default scorer used for relevance calculation is known as DefaultSimilarity
. In order to create a custom scorer, we will need to extend DefaultSimilarity
and create our own similarity class and eventually use it in our Solr schema. Solr also provides the option of specifying different similarity classes for different fieldTypes
configuration directive in the schema. Thus, we can create different similarity classes and then specify different scoring algorithms for different fieldTypes
as also a different global Similarity
class.
Let us create a custom scorer that disables the IDF factor of the scoring algorithm. ...
Get Apache Solr Search Patterns now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.