Remove the usage of nbHits from the code base
Closed this issue · 1 comments
The value nbHits
returned by MeiliSearch is not a trustable value since it's not an exhaustive value. nbHits
is indeed not reliable for pagination because can be exhaustive or not, depending on the value of exhaustiveNbHits
that MeiliSearch returns which is always false
We should implement the pagination as described here: meilisearch/documentation#561
FYI: The Meili team is aware of the confusion with nbHis
. Here are the different issues and comments about it to explain why it's confusing, and why we should not use it:
- meilisearch/meilisearch#1120
- meilisearch/documentation#561
- meilisearch/meilisearch-php#119 (comment)
We are sorry for this. We all hope this confusion will be fixed asap in MeiliSearch.
Related to #95
I realize my issue is not really relevant in this repo. The nbHits
is indeed not relevant (if the query involves a lot of results) but it's currently the only way to be compliant with Laravel/Scout.
Algolia, which implements the search the same way as MeiliSearch, also returns a non-reliable nbHits
but still uses it in Laravel/Scout:
https://github.com/laravel/scout/blob/78fb3b2e4837ed5d4e4a9fc1e09221aab774fe77/src/Engines/AlgoliaEngine.php#L198-L207
I'm closing this issue since it's not relevant anymore for this repo, but it might relevant for the next version of this library (meilisearch-laravel-scout-extended), see #111 for more details.