Comments (5)
@RightInTwo thanks, will do! I got pulled into other projects so my progress here is delayed, but I'll post an update when I finally get around to it.
from laravel-scout-typesense-driver.
We are also experiencing this issue on our team. The original issue explains the issue exactly so I don't feel a real need to add on details of our particular scenario.
However, I did dig into the source code of Laravel Scout and the Scout Typesense driver here and discovered the root of the problem (although I have not figured out an actual fix yet).
The base Laravel Scout Builder
object has a function called paginate
. This function actually issues two requests to the Typesense engine The first is to retrieve the paginated data, exactly the way you would expect. The second has to do with getting the total number of records, and herein lies the problem...
paginate
calls a function $this->getTotalCount()
. (https://github.com/laravel/scout/blob/9.x/src/Builder.php#L384)
getTotalCount
calls a function $engine->keys(...)
(https://github.com/laravel/scout/blob/9.x/src/Builder.php#L450) and passes in your $builder
instance, but not without injecting one little change first.
$builder->take(
is_null($this->limit) ? $totalCount : min($this->limit, $totalCount)
);
(https://github.com/laravel/scout/blob/9.x/src/Builder.php#L451-L453)
This code sets the limit
of the query to the total count which was already found in the first query! So when the keys
function calls $this->search(...)
. (https://github.com/laravel/scout/blob/9.x/src/Builder.php#L450), it cascades down into the Typesense driver, issues the second request to the Typesense instance, but because the limit
is set to the total number of entries, this triggers the Typesense error that only a maximum of 250 records can be fetched per page.
I will likely be working on a fork/fix/PR in the next few days, but I wanted to go ahead and document my findings here in case any other poor souls out in the world run into this issue.
One last thing I'd like to point out is that it is unclear to me whether this is a flaw with this package or with the laravel/scout
package. One would think that if this is the only driver experiencing issues, it must be this package, but it could also be that laravel/scout
is not built flexibly enough to account for restrictions such as provider-enforced maximum page size. For example the DatabaseDriver
only calls your database with a raw SQL query - it can (theoretically) query every record in the table without hitting an actual error. It is odd to me that a pagination query should issue two separate calls to search
... However, I have not really looked into the source of the other drivers to see how they handle this issue, so I can't be sure.
from laravel-scout-typesense-driver.
Same issue here! @nickrupert7 Hit me up if you can use any support/testing on this.
from laravel-scout-typesense-driver.
We've implemented a solution based on SQL Views that include the $relations with the joinRelations package. So this issue is not blocking us anymore...
from laravel-scout-typesense-driver.
Hi @nickrupert7, do you have a workaround? i was hit by this issue.
from laravel-scout-typesense-driver.
Related Issues (20)
- Laravel 10 Support HOT 10
- Error from Typesense on Update of Model Instance which is not in index HOT 2
- PHP 8.2 deprecation warnings HOT 1
- Laravel Scout 10? HOT 1
- Unable to sort HOT 4
- Error importing document: Field `itemStocks` not found. HOT 2
- "Undefined property: Laravel\\Scout\\Builder::$whereIns", HOT 1
- Filter in typesensne collection of objects in Laravel
- $model->unsearchable(); does not work HOT 7
- Import not working with array data. HOT 11
- Model update resets document auto-generated embeddings HOT 1
- Cannot index collection with a soft deleted first model when scout.soft_delete is true HOT 2
- Hotfix TypeError - Typesense\\Documents::import(): Argument #1 ($documents) must be of type string, array given. HOT 5
- Undefined property: Laravel\Scout\Builder::$whereIns HOT 1
- Passing "empty" values to search query results in "Parameter `q` is required"
- Please add possibility to use Laravel Scout Builder ->options() method
- Duplicate array keys in TypesenseEngine::buildSearchParams HOT 1
- Exception when searching large datasets for common query HOT 2
- Using Multi Search after merging to Laravel Scout HOT 2
- Typesense scout import fails in Laravel 11 HOT 1
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 laravel-scout-typesense-driver.