Skip to content

Commit 0d34985

Browse files
committed
Add CONTAINS relation to geo_shape query
At the time of geo_shape query conception, CONTAINS was not yet a supported spatial operation in Lucene. Since it is now available this commit adds ShapeRelation.CONTAINS to GeoShapeQuery. Randomized testing is included and documentation is updated.
1 parent 9ed77af commit 0d34985

File tree

6 files changed

+215
-136
lines changed

6 files changed

+215
-136
lines changed

core/src/main/java/org/elasticsearch/common/geo/ShapeRelation.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ public enum ShapeRelation implements Writeable<ShapeRelation>{
3434

3535
INTERSECTS("intersects"),
3636
DISJOINT("disjoint"),
37-
WITHIN("within");
37+
WITHIN("within"),
38+
CONTAINS("contains");
3839

3940
private final String relationName;
4041

core/src/main/java/org/elasticsearch/index/query/GeoShapeQueryBuilder.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ public static SpatialArgs getArgs(ShapeBuilder shape, ShapeRelation relation) {
361361
return new SpatialArgs(SpatialOperation.Intersects, shape.build());
362362
case WITHIN:
363363
return new SpatialArgs(SpatialOperation.IsWithin, shape.build());
364+
case CONTAINS:
365+
return new SpatialArgs(SpatialOperation.Contains, shape.build());
364366
default:
365367
throw new IllegalArgumentException("invalid relation [" + relation + "]");
366368
}

0 commit comments

Comments
 (0)