Skip to main content

Relevancy

Returning the score

The computed search score is available automatically through the $meta context. It can be added to documents using either $addFields or $project using {"$meta": "searchScore"}

Requesting score details

The complete formula used to compute the score can be enabled and returned. Generating the score details comes at a slight performance hit, so only do so for diagnostic purposes.

Like the score, once it has been enabled the score details can be returned using $addFields or $project.

  • Enable the score details by setting "scoreDetails": true within $search
  • The score details are then available using {"$meta": "searchScoreDetails"}

relevancy example