mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-22 20:12:11 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
61d8114513
@ -128,9 +128,9 @@ class CriteriaFilterProcessor {
|
||||
case BBOX: {
|
||||
filter = geoBoundingBoxFilter(fieldName);
|
||||
|
||||
Assert.isTrue(value instanceof Object[], "Value of a bbox filter should be an array of one or two values.");
|
||||
Assert.isTrue(value instanceof Object[], "Value of a boundedBy filter should be an array of one or two values.");
|
||||
Object[] valArray = (Object[]) value;
|
||||
Assert.noNullElements(valArray, "Geo bbox filter takes a not null element array as parameter.");
|
||||
Assert.noNullElements(valArray, "Geo boundedBy filter takes a not null element array as parameter.");
|
||||
|
||||
if (valArray.length == 1) {
|
||||
//GeoEnvelop
|
||||
@ -141,7 +141,7 @@ class CriteriaFilterProcessor {
|
||||
twoParameterBBox((GeoBoundingBoxFilterBuilder) filter, valArray);
|
||||
} else {
|
||||
//error
|
||||
Assert.isTrue(false, "Geo distance filter takes a 1-elements array(GeoEnvelop) or 2-elements array(GeoPoints or Strings(geohash)).");
|
||||
Assert.isTrue(false, "Geo distance filter takes a 1-elements array(GeoBox) or 2-elements array(GeoPoints or Strings(format lat,lon or geohash)).");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -152,7 +152,7 @@ class CriteriaFilterProcessor {
|
||||
}
|
||||
|
||||
private void oneParameterBBox(GeoBoundingBoxFilterBuilder filter, Object value) {
|
||||
Assert.isTrue(value instanceof GeoBox, "single-element of a geo bbox filter must be type of GeoEnvelop");
|
||||
Assert.isTrue(value instanceof GeoBox, "single-element of boundedBy filter must be type of GeoBox");
|
||||
GeoBox geoBBox = (GeoBox) value;
|
||||
filter.topLeft(geoBBox.getTopLeft().getLat(), geoBBox.getTopLeft().getLon());
|
||||
filter.bottomRight(geoBBox.getBottomRight().getLat(), geoBBox.getBottomRight().getLon());
|
||||
@ -168,7 +168,7 @@ class CriteriaFilterProcessor {
|
||||
}
|
||||
|
||||
private void twoParameterBBox(GeoBoundingBoxFilterBuilder filter, Object[] values) {
|
||||
Assert.isTrue(isType(values, GeoPoint.class) || isType(values, String.class), " both elements of geo bbox filter must be type of GeoPoint or String(geohash)");
|
||||
Assert.isTrue(isType(values, GeoPoint.class) || isType(values, String.class), " both elements of boundedBy filter must be type of GeoPoint or String(format lat,lon or geohash)");
|
||||
if (values[0] instanceof GeoPoint) {
|
||||
GeoPoint topLeft = (GeoPoint) values[0];
|
||||
GeoPoint bottomRight = (GeoPoint) values[1];
|
||||
|
@ -385,14 +385,14 @@ public class Criteria {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new CriteriaEntry for {@code location BBOX bounding box}
|
||||
* Creates new CriteriaEntry for {@code location GeoBox bounding box}
|
||||
*
|
||||
* @param bbox {@link org.springframework.data.elasticsearch.core.geo.GeoBox} bounding box(left top corner + right bottom corner)
|
||||
* @return Criteria the chaind criteria with the new 'bbox' criteria included.
|
||||
* @param boundingBox {@link org.springframework.data.elasticsearch.core.geo.GeoBox} bounding box(left top corner + right bottom corner)
|
||||
* @return Criteria the chaind criteria with the new 'boundingBox' criteria included.
|
||||
*/
|
||||
public Criteria bbox(GeoBox bbox) {
|
||||
Assert.notNull(bbox, "bbox value for bbox criteria must not be null");
|
||||
filterCriteria.add(new CriteriaEntry(OperationKey.BBOX, new Object[]{bbox}));
|
||||
public Criteria boundedBy(GeoBox boundingBox) {
|
||||
Assert.notNull(boundingBox, "boundingBox value for boundedBy criteria must not be null");
|
||||
filterCriteria.add(new CriteriaEntry(OperationKey.BBOX, new Object[]{boundingBox}));
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -400,28 +400,28 @@ public class Criteria {
|
||||
/**
|
||||
* Creates new CriteriaEntry for bounding box created from points
|
||||
*
|
||||
* @param topLeft left top corner of bounding box
|
||||
* @param bottomRight right bottom corner of bounding box
|
||||
* @return Criteria the chaind criteria with the new 'bbox' criteria included.
|
||||
* @param topLeftPoint left top corner of bounding box
|
||||
* @param bottomRightPoint right bottom corner of bounding box
|
||||
* @return Criteria the chaind criteria with the new 'boundedBy' criteria included.
|
||||
*/
|
||||
public Criteria bbox(String topLeft, String bottomRight) {
|
||||
Assert.isTrue(StringUtils.isNotBlank(topLeft), "topLeft point must not be empty");
|
||||
Assert.isTrue(StringUtils.isNotBlank(bottomRight), "bottomRight point must not be empty");
|
||||
filterCriteria.add(new CriteriaEntry(OperationKey.BBOX, new Object[]{topLeft, bottomRight}));
|
||||
public Criteria boundedBy(String topLeftPoint, String bottomRightPoint) {
|
||||
Assert.isTrue(StringUtils.isNotBlank(topLeftPoint), "topLeftPoint must not be empty");
|
||||
Assert.isTrue(StringUtils.isNotBlank(bottomRightPoint), "bottomRightPoint must not be empty");
|
||||
filterCriteria.add(new CriteriaEntry(OperationKey.BBOX, new Object[]{topLeftPoint, bottomRightPoint}));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new CriteriaEntry for bounding box created from points
|
||||
*
|
||||
* @param topLeft left top corner of bounding box
|
||||
* @param bottomRight right bottom corner of bounding box
|
||||
* @return Criteria the chaind criteria with the new 'bbox' criteria included.
|
||||
* @param topLeftPoint left top corner of bounding box
|
||||
* @param bottomRightPoint right bottom corner of bounding box
|
||||
* @return Criteria the chaind criteria with the new 'boundedBy' criteria included.
|
||||
*/
|
||||
public Criteria bbox(GeoPoint topLeft, GeoPoint bottomRight) {
|
||||
Assert.notNull(topLeft, "topLeft point must not be null");
|
||||
Assert.notNull(bottomRight, "bottomRight point must not be null");
|
||||
filterCriteria.add(new CriteriaEntry(OperationKey.BBOX, new Object[]{topLeft, bottomRight}));
|
||||
public Criteria boundedBy(GeoPoint topLeftPoint, GeoPoint bottomRightPoint) {
|
||||
Assert.notNull(topLeftPoint, "topLeftPoint must not be null");
|
||||
Assert.notNull(bottomRightPoint, "bottomRightPoint must not be null");
|
||||
filterCriteria.add(new CriteriaEntry(OperationKey.BBOX, new Object[]{topLeftPoint, bottomRightPoint}));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -186,11 +186,11 @@ public class ElasticsearchTemplateGeoTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFindAuthorMarkersInBoxForGivenCriteriaQueryUsingGeoEnvelop() {
|
||||
public void shouldFindAuthorMarkersInBoxForGivenCriteriaQueryUsingGeoBox() {
|
||||
//given
|
||||
loadClassBaseEntities();
|
||||
CriteriaQuery geoLocationCriteriaQuery3 = new CriteriaQuery(
|
||||
new Criteria("location").bbox(
|
||||
new Criteria("location").boundedBy(
|
||||
new GeoBox(new GeoPoint(53.5171d, 0),
|
||||
new GeoPoint(49.5171d, 0.2062d))));
|
||||
//when
|
||||
@ -206,7 +206,7 @@ public class ElasticsearchTemplateGeoTests {
|
||||
//given
|
||||
loadClassBaseEntities();
|
||||
CriteriaQuery geoLocationCriteriaQuery3 = new CriteriaQuery(
|
||||
new Criteria("location").bbox("53.5171d, 0", "49.5171d, 0.2062d"));
|
||||
new Criteria("location").boundedBy("53.5171d, 0", "49.5171d, 0.2062d"));
|
||||
//when
|
||||
List<AuthorMarkerEntity> geoAuthorsForGeoCriteria3 = elasticsearchTemplate.queryForList(geoLocationCriteriaQuery3, AuthorMarkerEntity.class);
|
||||
|
||||
@ -220,7 +220,7 @@ public class ElasticsearchTemplateGeoTests {
|
||||
//given
|
||||
loadClassBaseEntities();
|
||||
CriteriaQuery geoLocationCriteriaQuery3 = new CriteriaQuery(
|
||||
new Criteria("location").bbox(
|
||||
new Criteria("location").boundedBy(
|
||||
new GeoPoint(53.5171d, 0),
|
||||
new GeoPoint(49.5171d, 0.2062d)));
|
||||
//when
|
||||
|
Loading…
x
Reference in New Issue
Block a user