$boost operator adjusts the score contribution of a boolean clause.
Use it to fine-tune how much weight specific conditions have in the overall relevance ranking.
By default, all matching conditions contribute equally to a document’s relevance score.
The $boost operator multiplies a clause’s score contribution by the specified factor:
- Values greater than 1 increase importance (e.g.,
$boost: 5.0makes the clause 5x more important) - Values between 0 and 1 decrease importance
- Negative values demote matches, pushing them lower in results
$should conditions to prioritize certain matches:
$mustNot, which excludes documents entirely, negative boosting keeps documents in results but ranks them lower.
Examples
- TypeScript
- Redis CLI