Skip to content

Commit 61d8114

Browse files
author
Jakub Vavrik
committed
Merge remote-tracking branch 'upstream/master'
2 parents b5dfb59 + 99940f4 commit 61d8114

File tree

3 files changed

+29
-29
lines changed

3 files changed

+29
-29
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ private FilterBuilder processCriteriaEntry(OperationKey key, Object value, Strin
128128
case BBOX: {
129129
filter = geoBoundingBoxFilter(fieldName);
130130

131-
Assert.isTrue(value instanceof Object[], "Value of a bbox filter should be an array of one or two values.");
131+
Assert.isTrue(value instanceof Object[], "Value of a boundedBy filter should be an array of one or two values.");
132132
Object[] valArray = (Object[]) value;
133-
Assert.noNullElements(valArray, "Geo bbox filter takes a not null element array as parameter.");
133+
Assert.noNullElements(valArray, "Geo boundedBy filter takes a not null element array as parameter.");
134134

135135
if (valArray.length == 1) {
136136
//GeoEnvelop
@@ -141,7 +141,7 @@ private FilterBuilder processCriteriaEntry(OperationKey key, Object value, Strin
141141
twoParameterBBox((GeoBoundingBoxFilterBuilder) filter, valArray);
142142
} else {
143143
//error
144-
Assert.isTrue(false, "Geo distance filter takes a 1-elements array(GeoEnvelop) or 2-elements array(GeoPoints or Strings(geohash)).");
144+
Assert.isTrue(false, "Geo distance filter takes a 1-elements array(GeoBox) or 2-elements array(GeoPoints or Strings(format lat,lon or geohash)).");
145145
}
146146
break;
147147
}
@@ -152,7 +152,7 @@ private FilterBuilder processCriteriaEntry(OperationKey key, Object value, Strin
152152
}
153153

154154
private void oneParameterBBox(GeoBoundingBoxFilterBuilder filter, Object value) {
155-
Assert.isTrue(value instanceof GeoBox, "single-element of a geo bbox filter must be type of GeoEnvelop");
155+
Assert.isTrue(value instanceof GeoBox, "single-element of boundedBy filter must be type of GeoBox");
156156
GeoBox geoBBox = (GeoBox) value;
157157
filter.topLeft(geoBBox.getTopLeft().getLat(), geoBBox.getTopLeft().getLon());
158158
filter.bottomRight(geoBBox.getBottomRight().getLat(), geoBBox.getBottomRight().getLon());
@@ -168,7 +168,7 @@ private static boolean isType(Object[] array, Class clazz) {
168168
}
169169

170170
private void twoParameterBBox(GeoBoundingBoxFilterBuilder filter, Object[] values) {
171-
Assert.isTrue(isType(values, GeoPoint.class) || isType(values, String.class), " both elements of geo bbox filter must be type of GeoPoint or String(geohash)");
171+
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)");
172172
if (values[0] instanceof GeoPoint) {
173173
GeoPoint topLeft = (GeoPoint) values[0];
174174
GeoPoint bottomRight = (GeoPoint) values[1];

src/main/java/org/springframework/data/elasticsearch/core/query/Criteria.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -385,43 +385,43 @@ public Criteria within(String geoLocation, String distance) {
385385
}
386386

387387
/**
388-
* Creates new CriteriaEntry for {@code location BBOX bounding box}
388+
* Creates new CriteriaEntry for {@code location GeoBox bounding box}
389389
*
390-
* @param bbox {@link org.springframework.data.elasticsearch.core.geo.GeoBox} bounding box(left top corner + right bottom corner)
391-
* @return Criteria the chaind criteria with the new 'bbox' criteria included.
390+
* @param boundingBox {@link org.springframework.data.elasticsearch.core.geo.GeoBox} bounding box(left top corner + right bottom corner)
391+
* @return Criteria the chaind criteria with the new 'boundingBox' criteria included.
392392
*/
393-
public Criteria bbox(GeoBox bbox) {
394-
Assert.notNull(bbox, "bbox value for bbox criteria must not be null");
395-
filterCriteria.add(new CriteriaEntry(OperationKey.BBOX, new Object[]{bbox}));
393+
public Criteria boundedBy(GeoBox boundingBox) {
394+
Assert.notNull(boundingBox, "boundingBox value for boundedBy criteria must not be null");
395+
filterCriteria.add(new CriteriaEntry(OperationKey.BBOX, new Object[]{boundingBox}));
396396
return this;
397397
}
398398

399399

400400
/**
401401
* Creates new CriteriaEntry for bounding box created from points
402402
*
403-
* @param topLeft left top corner of bounding box
404-
* @param bottomRight right bottom corner of bounding box
405-
* @return Criteria the chaind criteria with the new 'bbox' criteria included.
403+
* @param topLeftPoint left top corner of bounding box
404+
* @param bottomRightPoint right bottom corner of bounding box
405+
* @return Criteria the chaind criteria with the new 'boundedBy' criteria included.
406406
*/
407-
public Criteria bbox(String topLeft, String bottomRight) {
408-
Assert.isTrue(StringUtils.isNotBlank(topLeft), "topLeft point must not be empty");
409-
Assert.isTrue(StringUtils.isNotBlank(bottomRight), "bottomRight point must not be empty");
410-
filterCriteria.add(new CriteriaEntry(OperationKey.BBOX, new Object[]{topLeft, bottomRight}));
407+
public Criteria boundedBy(String topLeftPoint, String bottomRightPoint) {
408+
Assert.isTrue(StringUtils.isNotBlank(topLeftPoint), "topLeftPoint must not be empty");
409+
Assert.isTrue(StringUtils.isNotBlank(bottomRightPoint), "bottomRightPoint must not be empty");
410+
filterCriteria.add(new CriteriaEntry(OperationKey.BBOX, new Object[]{topLeftPoint, bottomRightPoint}));
411411
return this;
412412
}
413413

414414
/**
415415
* Creates new CriteriaEntry for bounding box created from points
416416
*
417-
* @param topLeft left top corner of bounding box
418-
* @param bottomRight right bottom corner of bounding box
419-
* @return Criteria the chaind criteria with the new 'bbox' criteria included.
417+
* @param topLeftPoint left top corner of bounding box
418+
* @param bottomRightPoint right bottom corner of bounding box
419+
* @return Criteria the chaind criteria with the new 'boundedBy' criteria included.
420420
*/
421-
public Criteria bbox(GeoPoint topLeft, GeoPoint bottomRight) {
422-
Assert.notNull(topLeft, "topLeft point must not be null");
423-
Assert.notNull(bottomRight, "bottomRight point must not be null");
424-
filterCriteria.add(new CriteriaEntry(OperationKey.BBOX, new Object[]{topLeft, bottomRight}));
421+
public Criteria boundedBy(GeoPoint topLeftPoint, GeoPoint bottomRightPoint) {
422+
Assert.notNull(topLeftPoint, "topLeftPoint must not be null");
423+
Assert.notNull(bottomRightPoint, "bottomRightPoint must not be null");
424+
filterCriteria.add(new CriteriaEntry(OperationKey.BBOX, new Object[]{topLeftPoint, bottomRightPoint}));
425425
return this;
426426
}
427427

src/test/java/org/springframework/data/elasticsearch/core/geo/ElasticsearchTemplateGeoTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,11 @@ public void shouldFindAllMarkersForNativeSearchQuery() {
186186
}
187187

188188
@Test
189-
public void shouldFindAuthorMarkersInBoxForGivenCriteriaQueryUsingGeoEnvelop() {
189+
public void shouldFindAuthorMarkersInBoxForGivenCriteriaQueryUsingGeoBox() {
190190
//given
191191
loadClassBaseEntities();
192192
CriteriaQuery geoLocationCriteriaQuery3 = new CriteriaQuery(
193-
new Criteria("location").bbox(
193+
new Criteria("location").boundedBy(
194194
new GeoBox(new GeoPoint(53.5171d, 0),
195195
new GeoPoint(49.5171d, 0.2062d))));
196196
//when
@@ -206,7 +206,7 @@ public void shouldFindAuthorMarkersInBoxForGivenCriteriaQueryUsingString() {
206206
//given
207207
loadClassBaseEntities();
208208
CriteriaQuery geoLocationCriteriaQuery3 = new CriteriaQuery(
209-
new Criteria("location").bbox("53.5171d, 0", "49.5171d, 0.2062d"));
209+
new Criteria("location").boundedBy("53.5171d, 0", "49.5171d, 0.2062d"));
210210
//when
211211
List<AuthorMarkerEntity> geoAuthorsForGeoCriteria3 = elasticsearchTemplate.queryForList(geoLocationCriteriaQuery3, AuthorMarkerEntity.class);
212212

@@ -220,7 +220,7 @@ public void shouldFindAuthorMarkersInBoxForGivenCriteriaQueryUsingGeoPoints() {
220220
//given
221221
loadClassBaseEntities();
222222
CriteriaQuery geoLocationCriteriaQuery3 = new CriteriaQuery(
223-
new Criteria("location").bbox(
223+
new Criteria("location").boundedBy(
224224
new GeoPoint(53.5171d, 0),
225225
new GeoPoint(49.5171d, 0.2062d)));
226226
//when

0 commit comments

Comments
 (0)