From 4efec54e1d488bd81fb4c1eba2c744abdd36c9b8 Mon Sep 17 00:00:00 2001 From: Mohsin Husen Date: Sat, 13 Feb 2016 10:46:14 +0000 Subject: [PATCH] DATAES-211 - incorporate changes in GeoDistance --- .../elasticsearch/core/CriteriaFilterProcessor.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/springframework/data/elasticsearch/core/CriteriaFilterProcessor.java b/src/main/java/org/springframework/data/elasticsearch/core/CriteriaFilterProcessor.java index 514cf5242..3ee30937a 100644 --- a/src/main/java/org/springframework/data/elasticsearch/core/CriteriaFilterProcessor.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/CriteriaFilterProcessor.java @@ -107,7 +107,7 @@ class CriteriaFilterProcessor { switch (key) { case WITHIN: { - filter = QueryBuilders.geoDistanceRangeQuery(fieldName); + GeoDistanceQueryBuilder geoDistanceQueryBuilder = QueryBuilders.geoDistanceQuery(fieldName); Assert.isTrue(value instanceof Object[], "Value of a geo distance filter should be an array of two values."); Object[] valArray = (Object[]) value; @@ -126,19 +126,20 @@ class CriteriaFilterProcessor { if (valArray[0] instanceof GeoPoint) { GeoPoint loc = (GeoPoint) valArray[0]; - ((GeoDistanceRangeQueryBuilder) filter).lat(loc.getLat()).lon(loc.getLon()).geoDistance(GeoDistance.fromString(dist.toString())); + geoDistanceQueryBuilder.lat(loc.getLat()).lon(loc.getLon()).distance(dist.toString()).geoDistance(GeoDistance.PLANE); } else if (valArray[0] instanceof Point) { GeoPoint loc = GeoPoint.fromPoint((Point) valArray[0]); - ((GeoDistanceRangeQueryBuilder) filter).lat(loc.getLat()).lon(loc.getLon()).geoDistance(GeoDistance.fromString(dist.toString())); + geoDistanceQueryBuilder.lat(loc.getLat()).lon(loc.getLon()).distance(dist.toString()).geoDistance(GeoDistance.PLANE); } else { String loc = (String) valArray[0]; if (loc.contains(",")) { String c[] = loc.split(","); - ((GeoDistanceRangeQueryBuilder) filter).lat(Double.parseDouble(c[0])).lon(Double.parseDouble(c[1])).geoDistance(GeoDistance.fromString(dist.toString())); + geoDistanceQueryBuilder.lat(Double.parseDouble(c[0])).lon(Double.parseDouble(c[1])).distance(dist.toString()).geoDistance(GeoDistance.PLANE); } else { - ((GeoDistanceRangeQueryBuilder) filter).geohash(loc).geoDistance(GeoDistance.fromString(dist.toString())); + geoDistanceQueryBuilder.geohash(loc).distance(dist.toString()).geoDistance(GeoDistance.PLANE); } } + filter = geoDistanceQueryBuilder; break; }