We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
10.31
8.1
No response
OrderBy in Meilisearch does not work properly (Laravel Scout)
When using Meilisearch with Laravel Scout and using the orderBy feature, the results are NOT correct:
Illuminate\Support\Collection {#5719 all: [ 21637, 52590, 67247, 5060, 63499, 78632, 70287, 34339, 67494, 9276, ], }
public function toSearchableArray(): array { return Arr::only($this->toArray(), [ self::ID_COLUMN, self::TITLE_COLUMN, self::DESCRIPTION_COLUMN, self::VIEWS_COLUMN, self::CLICKS_COLUMN ]); }
'meilisearch' => [ 'host' => env('MEILISEARCH_HOST', 'http://localhost:7700'), 'key' => env('MEILISEARCH_KEY'), 'index-settings' => [ Post::class => [ 'sortableAttributes'=> [Post::ID_COLUMN, Post::VIEWS_COLUMN, Post::CLICKS_COLUMN], ], ], ],
return [ Post::TITLE_COLUMN => $this->faker->realText(100), Post::DESCRIPTION_COLUMN => $this->faker->realText(), Post::VIEWS_COLUMN => $views = (int)$this->faker->numberBetween(10, 100000), Post::CLICKS_COLUMN => (int) ($views / rand(2, 4)) ];
\App\Models\Post::search('t')->orderBy('views')->get()->pluck('views');
The text was updated successfully, but these errors were encountered:
@mmachatschek hmm from what I can tell they have the sortableAttributes correct here. Any idea why it's not working for them?
Sorry, something went wrong.
It seems that the issue was the rankingRules as Meilisearch was prioritizing "words" more than "sort", so the solution was adding the following:
'rankingRules' => ['sort']
Thanks @ismailnakkar. If anything should be made more clear in the docs we'd appreciate a PR 👍
No branches or pull requests
Laravel Version
10.31
PHP Version
8.1
Database Driver & Version
No response
Description
OrderBy in Meilisearch does not work properly (Laravel Scout)
When using Meilisearch with Laravel Scout and using the orderBy feature, the results are NOT correct:
Steps To Reproduce
\App\Models\Post::search('t')->orderBy('views')->get()->pluck('views');
The text was updated successfully, but these errors were encountered: