Comments (12)
@razvaniacob working on it. 👌
from scout.
@driesvints Typesense has a max of 250 hits per page, and beyond that we'd have to use the page
parameter to fetch additional pages. It looks like we're not managing this limit automatically within the Scout driver's pagination mechanism.
@karakhanyans is looking into this.
from scout.
@jasonbosco do you maybe know more about this?
from scout.
Hi @razvaniacob
I did setup a fresh project and could not reproduce the issue you are having.
- I have setup typesense driver
- Added Searchable to User model
- Configured schema
- Imported 10K users with factories
- And did search with pagination ( User::search('m')->paginate(10);
The results worked fine.
Here is the repo where I did all that. The results are returned with /users endpoint.
https://github.com/karakhanyans/laravel-scout-typesense
Could you please fork the repo, and add the steps that you did and push them so I can reproduce error?
Thanks.
from scout.
Thanks @karakhanyans,
I've tested with your code and it works.
So then I started experimenting with what I have so when I do something like this:
return ImportedProperty::search('pipera')->paginate(10)->onEachSide(1)->withQueryString()
->through(fn ($obj) => [
'name' => $obj->source_id,
]);
It works, but if I do it like this:
return ImportedProperty::search('pipera')
->query(fn (Builder $query) => $query->with(['imported_district', 'neighbourhood']))
->paginate(10)->onEachSide(1)->withQueryString()
->through(fn ($obj) => [
'name' => $obj->source_id,
'district' => $obj->imported_district?->name ?? ($obj->neighbourhood?->name ?? ''),
]);
It fails with the error
Maybe it has something to do with the
->query(fn (Builder $query) => $query->with(['imported_district', 'neighbourhood']))
line?
Any thoughts?
from scout.
@razvaniacob have you tried this line ->query(fn (Builder $query) => $query->with(['imported_district', 'neighbourhood']))
like this $query->with(['imported_district', 'neighbourhood'])
, without putting it inside query, as it's just a ->with.
from scout.
I followed the documentation found here Laravel Scout Documentation
If I do just ->with... I get this error
Method Laravel\Scout\Builder::with does not exist.
from scout.
This is an issue I also encountered, see: typesense/laravel-scout-typesense-driver#86
from scout.
Hey guys,
im getting the same issue when using queyr Builder
$posts = Post::search($text)
->query(fn (Builder $query) => $query->with(['images:id,name,path,extension']))
Removing it fixed the issue
from scout.
Thank you for reporting this issue!
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.
Thank you!
from scout.
I just ran into this as well when using paginate()
with query()
. Looks to me like the root cause is how getTotalCount
skips using the engine's result if a queryCallback
exists. That causes it to call take
with the $totalCount
result if there is no limit. That ends up calling Typesense with a per_page
value of $totalCount
triggering the error.
Lines 480 to 509 in 6e5b47d
As a workaround, because of the is_null($this->limit) ? $totalCount : min($this->limit, $totalCount)
check, setting a limit in parallel to the paginate call results in a per_page
value that's controlled.
This should workaround it for example and not affect pagination since it doesn't look at the $limit
value.
$items = Item::search($request-input('query', ''))
->take(10)
->paginate(10);
It's not clear to me why the existence of the queryCallback
should ignore the $totalCount
returned by the engine? Why should it force falling back to the query builder for count if the query callback's purpose is to be "invoked after the relevant models have already been retrieved from your application's search engine" as described in docs.
from scout.
@davidstoker thanks for your input, this helped a lot with solving this.
@razvaniacob
from scout.
Related Issues (20)
- Typesense: Import exception not properly thrown HOT 1
- We need more operators in where clauses HOT 2
- Warn when using null driver HOT 1
- use scopeSearch to allow searching on relationships HOT 1
- Artisan scout commands not defined. HOT 1
- Add a fake() for scout HOT 4
- Searchable not sync to meilisearch with other index HOT 1
- Laravel 11 Support? HOT 1
- MongoDB Support HOT 1
- Optimization of Reindexing in Laravel Scout HOT 2
- Typesense driver makes unnecessary api cals HOT 3
- Incorrect Total Count in Laravel Scout Pagination HOT 1
- paginate() + query() = wrong pagination HOT 2
- Scout import for large datasets fails after upgrading from 10.X to Laravel 11.X HOT 9
- Scout with Meilisearch, is sending all model data instead of just the specific data defined in the toSearchableArray() method. HOT 2
- Incorrect Total Count in Laravel Scout Pagination HOT 8
- Cannot save more than 1 item per collections HOT 4
- Implement `updateIndexSettings` for algolia search HOT 2
- [Algolia] Invalid syntax for numeric condition:status=open HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scout.