Closed francoism90 closed 3 years ago
i had the exact same problem this morning i submitted a PR for it : https://github.com/meilisearch/meilisearch-laravel-scout/pull/86
@francoism90 this happens when you call return $meilisearch->search($query, $options);
in your custom search query.
If you call Model::search()->get()
directly, the MeilisearchEngine::class
calls the ->rawSearch()
method and therefore returns an array instead of an SearchResult
object. So the fix for this is calling:
return Book::search('prince', function (Indexes $meilisearch, $query, $options) {
$options['limit'] = 10000;
return $meilisearch->rawSearch($query, $options);
})->get();
Hello guys,
Indeed for custom search you should use ->rawSearch()
I will update the doc accordingly.
this package work with array
a recent change to the php sdk use a SeachResult
class and I don't think I will change the behaviour soon.
@mmachatschek @shokme Thanks! This fixed the issue. :)
Just on question: is it possible to build an query using ->orWhere
? I would to search for multiple terms and receive the data using one query.
// Table:
{ name: 'Foo' },
{ name: 'Foo Bar' },
{ name: 'Foo 2'},
{ name: 'Bar 2'},
..
// Results:
return Book::search('prince', function (Indexes $meilisearch, $query, $options) {
$options['limit'] = 10000;
$options['filters'] = "name = 'foo' OR name = 'bar'";
return $meilisearch->rawSearch('', $options);
})->get();
This doesn't seem to return any documents, is this normal? Should you use multiple queries instead?
@francoism90 as far as I can tell, there is no such feature neither in laravel/scout nor in this package. This would be something that should be provided via a macro in your app for your specific usecase
Hello everyone! Thanks @mmachatschek for your help on this 😄 And I hope @francoism90 and @olivM this fix will solve your issue, I'm going to do a release right now, let me know!
the v0.12.3 is out on Packagist! https://packagist.org/packages/meilisearch/meilisearch-laravel-scout
I'm trying to add a custom search as seen in the example:
This always returns the following error:
I must be doing something wrong, does it expect to have filters set?
Thanks!