You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When performing a meilisearch query using ->get() everything works fine, I get back the default 20 rows and the totalHits is returned and correct.
As soon as I replace ->get() with ->paginate(20) it throws the error Undefined array key "totalHits" as the key is missing from the meilisearch $results passed to MeilisearchEngine.php getTotalCount() method.
If I alter the getTotalCount() method to return $results['totalHits'] ?? $results['nbHits'] I get paginated results as expected but only for one page even though $results['nbHits'] equals 1000.
As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.
If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.
Scout Version
10.11
Scout Driver
Meilisearch
Laravel Version
11.31
PHP Version
8.2
Database Driver & Version
MySQL 8.0.32
SDK Version
meilisearch/meilisearch-php v1.11
Meilisearch CLI Version
No response
Description
When performing a meilisearch query using
->get()
everything works fine, I get back the default 20 rows and the totalHits is returned and correct.As soon as I replace
->get()
with->paginate(20)
it throws the error Undefined array key "totalHits" as the key is missing from the meilisearch $results passed to MeilisearchEngine.php getTotalCount() method.If I alter the getTotalCount() method to
return $results['totalHits'] ?? $results['nbHits']
I get paginated results as expected but only for one page even though $results['nbHits'] equals 1000.Here is my code in the controller:
$filters = [ "filter" => "price.amount >= 100 AND price.amount <= 200" ];`
$results = Property::search($search, function(Indexes $meilisearch, $query, $options) use ($filters) {
return $meilisearch->search($query, $filters);
})
->query(fn (Builder $query) => $query->withCount(['images']))
->paginate(20);
The above code only works with my hack.
Steps To Reproduce
As above.
The text was updated successfully, but these errors were encountered: