Web / Apache Solr Interview questions
What is the difference between Solr's standard scoring and function queries?
Solr's default relevance scoring uses BM25 (the modern default similarity, replacing the older TF-IDF-based classic similarity), which ranks documents by term frequency, inverse document frequency, and field length normalization - purely based on how well the text matches the query terms.
Function queries step outside pure text relevance and let you compute a score, or a boost, from arbitrary field values and math functions - things text similarity alone can't express, like recency, popularity, or geo-distance.
| Standard (BM25) scoring | Function queries |
| Based purely on term statistics | Based on field values and math (recip, linear, ms, geodist, etc.) |
| Applied automatically to every text query | Opted into via bf, boost, or _val_/frange |
/select?q=laptop &defType=edismax &bf=recip(ms(NOW,last_updated),3.16e-11,1,1)
The example above boosts more recently updated documents using bf (boost function) alongside normal text relevance from q. In practice, most production relevance tuning combines both: BM25 provides the base text match quality, and function queries layer in business signals - freshness, price, click-through rate - on top, since neither approach alone captures both text relevance and business priority.
More Related questions...