Skip to content
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

Make hitsCount always the number of hits (and not totalHits value) #701

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

johnnynotsolucky
Copy link
Contributor

Pull Request

Related issue

Fixes #700

What does this PR do?

  • Ensures that SearchResults::hitsCount is consistent regardless of whether estimatedTotalHits is set.

PR checklist

Please check if your PR fulfills the following requirements:

  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

@norkunas norkunas requested review from curquiza and Strift December 6, 2024 05:52
Copy link
Member

@curquiza curquiza left a comment

Choose a reason for hiding this comment

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

Hello

This is more a maintenance change here, nothing that impacts the product because totalHits is already supposed to always be the count of hits

Did you ask for this change because you noticed totalHits was different from the number of hits @johnnynotsolucky?

@johnnynotsolucky
Copy link
Contributor Author

Hi @curquiza, I noticed that when estimatedTotalHits is not set, then hitsCount has the same value as totalHits, which I think isn't correct. I would expect the value of hitsCount to always be the count of hits on the current page of results, whereas totalHit is the count or estimated count of hits across all pages.

Copy link
Member

@curquiza curquiza left a comment

Choose a reason for hiding this comment

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

Sorry, I did not understand immediately the problem,

it's indeed a bug here!

hitsCount is the number of hits, and totalHits the total exhaustive number of hits

@curquiza curquiza added the bug Something isn't working label Dec 9, 2024
Copy link
Member

@curquiza curquiza left a comment

Choose a reason for hiding this comment

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

thank you for this bug fix

bors merge

@curquiza curquiza changed the title Ensure that hitsCount value is always consistent Make hitsCount always the number of hits (and not totalHits value) Dec 9, 2024
@meili-bors meili-bors bot merged commit c5b229c into meilisearch:main Dec 9, 2024
31 of 33 checks passed
@johnnynotsolucky johnnynotsolucky deleted the consistent-hitscount branch December 9, 2024 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

hitsCount is the same as totalHits if estimatedTotalHits is not set
2 participants