meilisearch / meilisearch-laravel-scout

MeiliSearch integration for Laravel Scout
https://github.com/meilisearch/MeiliSearch
MIT License
465 stars 43 forks source link

Remove the usage of nbHits from the code base #97

Closed curquiza closed 3 years ago

curquiza commented 3 years ago

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: https://github.com/meilisearch/documentation/issues/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:

We are sorry for this. We all hope this confusion will be fixed asap in MeiliSearch.


Related to https://github.com/meilisearch/meilisearch-laravel-scout/issues/95

curquiza commented 3 years ago

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.