👐 Exercises
project the score
🔗 Playground link: score not projectedFix this Playground so that the score being projected is the relevancy score Atlas Search uses for default sorting.
Solution
The score is available in the pipeline $meta context as searchScore.
{"$meta": "searchScore"}
project the score details
🔗 Playground link: add the score details into the resultsEnable the score details and project them into the results.
Solution
Enable the score details with this setting in $search:
scoreDetails: true
Include the score details by adding this to $addFields:
"scoreDetails": {
"$meta": "searchScoreDetails"
}
score/sort by the weight field
🔗 Playground link: task: score documents by document field
Set the search (relevance) score to the value of the weight field.
Solution
Use the weight value as the score for the compound operator:
"score": {
"function": {
"path": "weight"
}
}