Closed mxmtsk closed 2 years ago
@mxmtsk please try to get in touch with a support channel on MeiliSearch Slack they will get you up and running. This issue looks to me like an implementation problem, specific to your usecase.
Seems like a feature request to me. Feel free to submit a PR or open an issue on the meilisearch repo.
Hi, i have the same problem. Is there an solution in the meantime?
Cheers Ralf
Hello @homeoftheunits
You can contact our support (the Meilisearch support) by sharing the detailed steps to reproduce, including the Meilisearch error you get at the final step.
Before contacting us, you might want to check your settings are well being imported to Meilisearch using this route.
I know. But it looks like, that it's an Scout Problem. I check this
Update for those looking for a quick fix :
After looking at Meilisearch logs i found an error during the index :
"The document with the id: `1` contains an invalid _geo field: `{\"lat\":\"52.51667\",\"lng\":\"13.38333\"}`."
When checking the docs, lat
and lng
are supposed to be float and not string : https://docs.meilisearch.com/learn/advanced/geosearch.html#preparing-documents-for-location-based-search
My guess is that the geo fields are not properly changed back to float when indexed by Meilisearch, casting them to float in the toSearchableArray
method fixed this for me.
In database the values were stored as float, but that didn't seems to be enough.
Hope this will be useful.
public function toSearchableArray(): array
{
return [
'_geo' => [
'lat' => (float) $this->geo_lat,
'lng' => (float) $this->geo_lng,
],
];
}
The solution proposed by @Schipsi resolved the issue for me as well. Without the cast to float
my index remains empty despite flushing and updating the indices. Looks to me like an issue with laravel/scout
.
Hello! FYI, once Meilisearch v0.28.0 will be out, this problem will not exist anymore! Just don't forget to update your meilisearch-php client when upgrading your Meilisearch version!
I'm using meilisearch v0.29.0, however the _geo index remains empty despite flushing and updating the indices. tried both by casting as float and string.
'_geo' => [ 'lat' => (float) $this->latitude, 'lng' => (float) $this->longitude, ],
Description:
To make some attributes filterable and sortable I've written a small artisan command to do the work for me. Now I wanna use Meilisearch's Geosearch functionality. For that, I added
_geo
to the array of filterable and sortable attributes by using Laravel Scouts respective methods.It doesn't throw an error but it also doesn't make the attributes filterable or sortable anymore.
This is the code:
To check if this is an issue with Meilisearch, I've executed the same command directly on Meilisearch, which worked without a problem:
Update response
Steps To Reproduce:
_geo
fields to any model: