Range query for geolocation in elasticsearch 6.x


(Arun Desai) #1

Hello,

How do I migrate the following range query used for geo location in elasticsearch 2.x to elasticsearch 6.x as it does not return any results in 6.x?

BoolQueryBuilder result;
result.must(QueryBuilders.rangeQuery("location.lat").gte(form.getMinLat()).lte(form.getMaxLat()));

result.must(QueryBuilders.rangeQuery("location.lon").gte(form.getMinLng()).lte(form.getMaxLng()));

I tried using the following in elasticsearch 6.x however it does not return the same results as in elasticsearch 2.x?

result.must(QueryBuilders.geoBoundingBoxQuery("location")
.setCorners(form.getMaxLat(), form.getMaxLng(), form.getMinLat(), form.getMinLng()))

Any help is highly appreciated.

Thanks.


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.