Functionality that provides details of how a score was calculated for an individual document
Every document returned by an Atlas Search query is assigned a score based on relevance. Many factors can influence a document's score, including the position of the search term in the document, the frequency of occurrence of the search term in the document, the type of operator the query uses, the type of analyzer the query uses, etc.
We do have an explain functionality in Atlas Search, which returns information about the $search query plan and execution statistics. The results returned by explain("executionStats") has a section on score, which provides statistics related to scoring documents in the result set. However, while the aforementioned statistics information provides details on the number of invocations and the nanos elapsed, it does not exactly tell "how" the score was calculated for each document.
This is an enhancement request for introducing such a functionality that can provide the specific details on how the score(s) are calculated for individual document(s).
[Changelog] Added scoreDetails boolean option to retrieve a detailed breakdown of the score for each document in the query results.
great idea, we need to know this
we really would appreciate having this functionality for various services in our system.
It would be great to be able to predict a document's final score and possibly the expected output range (min and max score). A relevant use case would be to programmatically identify good and bad matches based on predefined thresholds. This would open the door to using Atlas Search within automated pipelines, not just for human-facing searches.
For MongoDB Atlas Search queries it is currently not possible to get details about how the score is computed.
This information would be very helpful to fine-tune the boosting configuration for a query.
An appropriate Lucene method is available to get a scoring explanation: https://lucene.apache.org/core/8_11_0/core/org/apache/lucene/search/IndexSearcher.html#explain-org.apache.lucene.search.Query-int-