Range query for geolocation in elasticsearch 6.x

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.

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