We are migrating to ES and need to support different geo queries. We use a geo_point field type in our mapping. I can see that ES supports geo_bounding_box & geo_distance but I'm trying to figure out whether they can be used for our use cases below:
1.BBOX: where the box is defined using a central point & radius. As far as I understand, the geo_distance will create a circular shape, how can we use a bbox of that circle?
//something like this - but we want a box shape not circle QueryBuilders.geoDistanceQuery("location") .point(lat, lon) .distance(r, DistanceUnit.KILOMETERS);
2.LAT_WITHIN: how can we check for documents with latitude that is within a distance (north & south) from a central latitude?
//something like this - but with only lat & radius QueryBuilders.geoDistanceQuery(pointField) .point(lat) //only lat? .distance(r, DistanceUnit.KILOMETERS);
3.LON_WITHIN: similarly to the above point but for longitude.
4.SAME POINT: find documents with the same lat & lon. So can we use here the geo point field in a term query or is it possible to use the lat/lon keys?
using the first query below gives error "Geo fields do not support exact searching, use dedicated geo queries instead: [location]". The second query doesn't return results.
//point equal - this gives error QueryBuilders.termQuery("location", "lat,lon"); //OR - this doesn't return QueryBuilders.boolQuery() .must(QueryBuilders.termQuery("location.lat", lat)) .must(QueryBuilders.termQuery("location.lon", lon));