laravel-scout-elasticsearch
laravel-scout-elasticsearch copied to clipboard
[Feature] Question? MixedSearch - How to eager load realtionships and use pagination() at same time?
$data = MixedSearch::search($request->q ?? '')->within(implode(',', $searchTypes))->query(function ($query) {
$query->with('media');
})->get();
I would like to eager load some relationship and use pagination. If I use paginate() with query(), it throws SQLSTATE[42000]: Syntax error or access violation
.
SELECT count(*) AS aggregate FROM `mixed_search`.`php:20$20cs` WHERE `mixed_search`.`php:20$20cs`.`id` IN (7, 9, 4, 5)
@PitchRE Did you try this approach to load relations? https://github.com/matchish/laravel-scout-elasticsearch#eager-load