I'm getting some odd behaviour when doing geo_distance queries via the Rest High Level API on elasticsearch v6.2.4.
For example, my query is this:
{
"from":0,
"size":20,
"query": {
"bool": {
"must": [{
"geo_distance": {
"location":[34.06388166666667,-118.358675],
"distance":1.0,
"distance_type":"arc",
"validation_method":"STRICT",
"ignore_unmapped":false,
"boost":1.0
}
}],
"adjust_pure_negative":true,
"boost": 1.0
}
},
"explain":false,
"_source":{"includes":[],"excludes":[]}
}
But it responds with this as the root_cause
:
"type":"query_parsing_exception",
"reason":"illegal latitude value [264.375] for [geo_distance]"
What's happening here? That is not the latitude I queried with, as you can see.
Any help is much appreciated.
Update: I also notice that in the query the values are presented as [lon,lat]
rather than [lat,lon]
. I'm using the QueryBuilder correctly:
QueryBuilders.geoDistanceQuery(LOCATION_FIELD)
.point(lat, lon)
.distance(distance, unit)
.geoDistance(geoDistance));
According to the point
method in the builder:
public GeoDistanceQueryBuilder point(double lat, double lon) {
...