Web / Apache Solr Interview questions
When should you use a custom similarity or scoring function in Solr?
Solr's default BM25Similarity works well for general text relevance, so custom scoring should be reserved for cases where the default assumptions genuinely don't fit the domain, rather than applied as a default optimization step.
- Domain-specific term importance - if certain terms should never be down-weighted by document length normalization (e.g. short SKU codes vs. long descriptions), a per-field
Similarityoverride lets you tune or disable length norms independently per field. - Non-text ranking signals dominate - if business priority (sponsored placement, inventory level, margin) matters more than subtle text relevance differences, function queries and boost queries (
bf,bq) at query time are usually sufficient and far easier to maintain than a custom Similarity class. - A fundamentally different scoring model is needed - for example, implementing a custom
Similarityto replicate a specific academic ranking formula, or integrating an external relevance model's score via a plugin.
In practice, most relevance problems that look like "we need custom scoring" are actually solved by combining eDisMax field boosts (qf=title^3 description^1) with a handful of function query boosts, without writing a single line of custom Java Similarity code. Full custom Similarity implementations are relatively rare in production because they add real maintenance and testing burden, and are best reserved for cases where query-time boosting genuinely can't express the needed ranking behavior.
More Related questions...