Skip to content

v1.16: rankingScoreThreshold no longer affects totalHits accuracy #3322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: v1.16
Choose a base branch
from

Conversation

guimachiavelli
Copy link
Member

Fixes #3309

@guimachiavelli guimachiavelli marked this pull request as ready for review July 23, 2025 17:10
@guimachiavelli guimachiavelli requested a review from Mubelotix July 23, 2025 17:11
Comment on lines +1144 to +1146
When using `rankingScoreThreshold`, queries paginating results with `limit` and `offset` may exaggerate the count of `estimatedTotalHits`. For performance reasons, if the number of documents above `rankingScoreThreshold` is higher than `limit`, Meilisearch does not evaluate the ranking score of the remaining documents. Results ranking below the threshold are not immediately removed from the set of candidates.

Queries using `page` and `hitsPerPage` are unnaffected by this issue and `totalHits` should always display the correct total number of search results.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the whole bug is fixed and the warning can be removed. We could still warn users that the route may be slower than it was before.

Suggested change
When using `rankingScoreThreshold`, queries paginating results with `limit` and `offset` may exaggerate the count of `estimatedTotalHits`. For performance reasons, if the number of documents above `rankingScoreThreshold` is higher than `limit`, Meilisearch does not evaluate the ranking score of the remaining documents. Results ranking below the threshold are not immediately removed from the set of candidates.
Queries using `page` and `hitsPerPage` are unnaffected by this issue and `totalHits` should always display the correct total number of search results.
Using `rankingScoreThreshold` with `limit` and `offset` forces Meilisearch to evaluate the ranking score of all matching documents to return an accurate `totalHits`, which can impact performance.
In contrast, queries using `page` and `hitsPerPage` avoid this overhead and may benefit from significantly faster response times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v1.16: page and hitsPerPage return correct values when used with rankingScoreThreshold
2 participants