Closed razvaniacob closed 5 months ago
Hey there,
Can you first please try one of the support channels below? If you can actually identify this as a bug, feel free to open up a new issue with a link to the original one and we'll gladly help you out.
Thanks!
@driesvints Same issue here. This is a bug.
@razvaniacob
return $this->model->search()
->query(fn(Builder $query) => $query->with(['mainListingImage']))
->options([
'query_by' => 'vehicle_description, transmission, fuel_type, colour, year'
])
->paginate(12)
->withQueryString();```
if ->query() is removed then it is correct again
Scout Version
10.8.5
Scout Driver
Typesense
Laravel Version
11.2
PHP Version
8.3.3
Database Driver & Version
No response
SDK Version
No response
Meilisearch CLI Version
No response
Description
When using Laravel Scout for searching with pagination, I'm encountering an issue where the total count of records returned by the pagination (
paginate(200)
) method is equal to the number of items per page specified (200
), instead of reflecting the actual total number of matching records.Steps To Reproduce
Observe that the LengthAwarePaginator returned indicates a total of 200 records, regardless of the actual total count of matching records. When I changed it to 10 per page I got a total of 10 records found.
Expected Behavior: The total count ($searchResults->total()) returned by Laravel Scout's pagination should accurately reflect the complete number of records that match the search criteria ('pipera'), independent of the pagination settings.
Actual Behavior: The total count ($searchResults->total()) is consistently equal to the number of items per page specified in paginate(200), leading to an incorrect representation of the total number of matching records.
Output of dd() showing the LengthAwarePaginator and its properties.
Currently, there is no workaround as the issue seems to be related to the pagination behavior within Laravel Scout.
Please advise on how to resolve this issue or if any additional information is required to further investigate.
Thank you.