mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-08 21:22:12 +00:00
DATAES-211 - incorporate changes in GeoDistance
This commit is contained in:
parent
c7313b52eb
commit
4efec54e1d
@ -107,7 +107,7 @@ class CriteriaFilterProcessor {
|
|||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case WITHIN: {
|
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.");
|
Assert.isTrue(value instanceof Object[], "Value of a geo distance filter should be an array of two values.");
|
||||||
Object[] valArray = (Object[]) value;
|
Object[] valArray = (Object[]) value;
|
||||||
@ -126,19 +126,20 @@ class CriteriaFilterProcessor {
|
|||||||
|
|
||||||
if (valArray[0] instanceof GeoPoint) {
|
if (valArray[0] instanceof GeoPoint) {
|
||||||
GeoPoint loc = (GeoPoint) valArray[0];
|
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) {
|
} else if (valArray[0] instanceof Point) {
|
||||||
GeoPoint loc = GeoPoint.fromPoint((Point) valArray[0]);
|
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 {
|
} else {
|
||||||
String loc = (String) valArray[0];
|
String loc = (String) valArray[0];
|
||||||
if (loc.contains(",")) {
|
if (loc.contains(",")) {
|
||||||
String c[] = loc.split(",");
|
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 {
|
} else {
|
||||||
((GeoDistanceRangeQueryBuilder) filter).geohash(loc).geoDistance(GeoDistance.fromString(dist.toString()));
|
geoDistanceQueryBuilder.geohash(loc).distance(dist.toString()).geoDistance(GeoDistance.PLANE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
filter = geoDistanceQueryBuilder;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user