-
Notifications
You must be signed in to change notification settings - Fork 242
Scout orderBy() not supported #86
Comments
Can you provide an example of what you tried? I have an application where I'm using |
In my case, I used two simple text fields (name, description). I did not create any special mapping beforehand. Then, orderBy('name') didn't work. |
I just tried adding a sort on a text field ( Following this error message I tried changing it to the following (add ->orderBy('asset_name.keyword') And it worked, I got my result ordered alphabetically by this field. Edit: Got the idea to add I don't feel like this is something that should be fixed in this project though, as we can't really know of what type the specified order-column is. |
Thanks for the hint. Unfortunately adding ".keyword" didn't work out for me either. I will try it again later, when I have more time to track the issue down. |
I seem to have similar issue with Algolia implementation - here's my controller method: public function search(Request $request): JsonResponse
{
$query = Agent::query();
if (!is_null($keyword = $request->get('keyword'))) {
$query = Agent::search($keyword);
}
if (!is_null($sort = $request->get('sort')) && !is_null($direction = $request->get('direction'))) {
$query->orderBy($sort, $direction === 'desc' ? 'desc' : 'asc');
} else {
$query->orderBy('firstname')->orderBy('lastname');
}
$agents = $query->paginate(10);
return new JsonResponse($agents);
} When I call with I have no default sorting set up on the algolia index for this searchable. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
The function orderBy() on the Scout query builder has no effect here (or is buggy).
The text was updated successfully, but these errors were encountered: