Having an issue with geo distance sorting with elasticsearch where an error is being returned when attempting to define the location pin. Using the Elastica PHP client.
$base->addSort([
'_geo_distance' => [
'location' => $location,
'order' => 'asc',
'unit' => 'm'
]
]);
The error is;
illegal latitude value [269.58378318697214] for [GeoDistanceSort] [reason: all shards failed]
This suggests the value of the latitude is >180 but the value is only 51.561965753874624 with a longitude of -0.38245278430174103 (as retrieved from google maps).
I've checked the values are still as above before they are entered into the sort function.
I found the issue to be that elasticsearch doesn't like how accurate the map location is!
I implemented the following to round the values to 6 decimal places, and it worked a treat.
foreach ($mapcentre as $deg) {
$location[] = round($deg, 6);
}