-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
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
AlgoliaSearch \ AlgoliaException (400) _geoloc attribute cannot contains a string #554
Comments
Everything else is working with Algolia Search and Laravel. Algolia just will not accept latitude/longitude in the required _geoloc format. |
@mikestratton Thanks for reporting this! We will take a look next Monday. |
More information: // composer.json // In the model // Migration Database /* Latitude and Longitude are generated by submitting zip code to Google's GeoCoding API. Array is returned $geo[13.456, 91.2345] */ |
Hi @mikestratton, thanks for reporting this issue. Keep in mind that $geoloc = array('lat'=>$lat,'lng'=>$lng);
$input['_geoloc'] = $geoloc; Give it a try, and tell me if it works for you. |
I already tried that - I get an array to string conversion error from illuminate.
|
Can't save an array in the database without serialize or conversion to string or object. Algolia is receiving the data after it has been stored as a record in MySQL, correct? |
Serialize showing the same AlgoliaSearch string error, obviously. $geoloc = array('lat'=>$lat,'lng'=>$lng);
$input['_geoloc'] = serialize($geoloc); |
Thanks @mikestratton for providing me more details. I've tested your problem locally and I have the same issue. This is what you should do to avoid the conflicts between your local storage and your Algolia index. On your model you must add this : public function toSearchableArray()
{
$input = $this->toArray();
$input['_geoloc'] = [
'lat' => $input['lat'],
'lng' => $input['lng'],
];
unset($input['lat'], $input['lng']);
return $input;
} If you want more informations there is an article written by one of our engineer @julienbourdeau : GeoSearch Give it a try, and tell me if it works for you. |
Hooray, it works! Thank you. |
Cannot send location data (_geoloc{ 'lat'=> 0.00, 'lng'=>0.00}) to Algolia from Laravel application.
Here is the error:
AlgoliaSearch \ AlgoliaException (400) _geoloc attribute cannot contains a string near line:1 column:587 C:\xampp\htdocs\laravel\vendor\algolia\algoliasearch-client-php\src\AlgoliaSearch\Client.php
Here is the code in the controller:
$geoloc = array('lat'=>$lat,'lng'=>$lng); $input['_geoloc'] = json_encode($geoloc);
The text was updated successfully, but these errors were encountered: