Closed thannaske closed 4 months ago
It's not possible to combine query
and paginate
in a reliable with Scout. Please see many previous issues around this: https://github.com/laravel/scout/issues?q=is%3Aissue+query+paginate+is%3Aclosed
If there are that many issues around that topic, it's clearly missing in the documentation.
Please take a look at here to see if it's any help
If there are that many issues around that topic, it's clearly missing in the documentation.
agreed 1000%. If people still comes and complain about the same thing, maybe its good idea to just add one line in the documentation like "Note that you could not combine query() with paginate()"
If there are that many issues around that topic, it's clearly missing in the documentation.
agreed 1000%. If people still comes and complain about the same thing, maybe its good idea to just add one line in the documentation like "Note that you could not combine query() with paginate()"
The same question was asked on #825 and resolved accordingly. If your case seems to be different and you're still encountering errors regarding pagination, please provide a reproducible example so we can take a deeper look
The same question was asked on #825 and resolved accordingly. If your case seems to be different and you're still encountering errors regarding pagination, please provide a reproducible example so we can take a deeper look
Unfortunately, the solution doesn't work in my case. I checked src/Engines/TypesenseEngine.php, everything is the same as in PR, but the problem remains.
The same question was asked on #825 and resolved accordingly. If your case seems to be different and you're still encountering errors regarding pagination, please provide a reproducible example so we can take a deeper look
Unfortunately, the solution doesn't work in my case. I checked src/Engines/TypesenseEngine.php, everything is the same as in PR, but the problem remains.
Could you open up a new Issue with an example so we can take a deeper look into it?
Scout Version
10.10.1
Scout Driver
Typesense
Laravel Version
10.48.16
PHP Version
8.3
Database Driver & Version
No response
SDK Version
Typesense PHP 4.9.3
Meilisearch CLI Version
No response
Description
Summary
When searching a model using Scout with the Typesense driver, using the
query()
method in combination with thepaginate()
method causes the pagination to return only the firstn
results (depending on the max items per page).Example with
query()
methodIn my concrete implementation, I'm searching through the full-text of messages. When displaying them, I need several relationships to be eagerly loaded in order to avoid n+1 query issues. According to the documentation, the
query()
method can used for such things:As you can see, we're searching by the
content
field in Typesense, applying some filtering and then applying some eager loading on all models found by the Scout search before paginating the results.The following code above leads to the following result (shortened for readability):
A
LengthAwarePaginator
is correctly being returned, and it shows a total of 10 results.Example without
query()
methodNow I'm commenting out the
query
method but leaving the rest of the code completely untouched:This now yields the following result:
The exact same search query now yields 176 total results with a total of 18 paginated pages which matches my test dataset. The only difference is now that no eager loading can be performed as the
query()
method has been commented out.Steps To Reproduce
Message
with acontent
attribute and create and save several instances with similar or same contentAuthor
to have a relationship that can be eagerly loadedquery()
method and compare the results