Skip to content

Commit 4efec54

Browse files
committed
DATAES-211 - incorporate changes in GeoDistance
1 parent c7313b5 commit 4efec54

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/java/org/springframework/data/elasticsearch/core/CriteriaFilterProcessor.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ private QueryBuilder processCriteriaEntry(OperationKey key, Object value, String
107107

108108
switch (key) {
109109
case WITHIN: {
110-
filter = QueryBuilders.geoDistanceRangeQuery(fieldName);
110+
GeoDistanceQueryBuilder geoDistanceQueryBuilder = QueryBuilders.geoDistanceQuery(fieldName);
111111

112112
Assert.isTrue(value instanceof Object[], "Value of a geo distance filter should be an array of two values.");
113113
Object[] valArray = (Object[]) value;
@@ -126,19 +126,20 @@ private QueryBuilder processCriteriaEntry(OperationKey key, Object value, String
126126

127127
if (valArray[0] instanceof GeoPoint) {
128128
GeoPoint loc = (GeoPoint) valArray[0];
129-
((GeoDistanceRangeQueryBuilder) filter).lat(loc.getLat()).lon(loc.getLon()).geoDistance(GeoDistance.fromString(dist.toString()));
129+
geoDistanceQueryBuilder.lat(loc.getLat()).lon(loc.getLon()).distance(dist.toString()).geoDistance(GeoDistance.PLANE);
130130
} else if (valArray[0] instanceof Point) {
131131
GeoPoint loc = GeoPoint.fromPoint((Point) valArray[0]);
132-
((GeoDistanceRangeQueryBuilder) filter).lat(loc.getLat()).lon(loc.getLon()).geoDistance(GeoDistance.fromString(dist.toString()));
132+
geoDistanceQueryBuilder.lat(loc.getLat()).lon(loc.getLon()).distance(dist.toString()).geoDistance(GeoDistance.PLANE);
133133
} else {
134134
String loc = (String) valArray[0];
135135
if (loc.contains(",")) {
136136
String c[] = loc.split(",");
137-
((GeoDistanceRangeQueryBuilder) filter).lat(Double.parseDouble(c[0])).lon(Double.parseDouble(c[1])).geoDistance(GeoDistance.fromString(dist.toString()));
137+
geoDistanceQueryBuilder.lat(Double.parseDouble(c[0])).lon(Double.parseDouble(c[1])).distance(dist.toString()).geoDistance(GeoDistance.PLANE);
138138
} else {
139-
((GeoDistanceRangeQueryBuilder) filter).geohash(loc).geoDistance(GeoDistance.fromString(dist.toString()));
139+
geoDistanceQueryBuilder.geohash(loc).distance(dist.toString()).geoDistance(GeoDistance.PLANE);
140140
}
141141
}
142+
filter = geoDistanceQueryBuilder;
142143

143144
break;
144145
}

0 commit comments

Comments
 (0)