Skip to content

Commit 9c4ea84

Browse files
nknizejkakavas
authored andcommitted
[GEO] Fix GeoShapeQueryBuilder to check for valid spatial relations
Refactor left out the spatial strategy check in GeoShapeQueryBuilder.relation setter method. This commit adds that check back in.
1 parent 24e009b commit 9c4ea84

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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

+18
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,24 @@ public String getWriteableName() {
173173
return NAME;
174174
}
175175

176+
/**
177+
* Sets the relation of query shape and indexed shape.
178+
*
179+
* @param relation relation of the shapes
180+
* @return this
181+
*/
182+
public GeoShapeQueryBuilder relation(ShapeRelation relation) {
183+
if (relation == null) {
184+
throw new IllegalArgumentException("No Shape Relation defined");
185+
}
186+
if (SpatialStrategy.TERM.equals(strategy) && relation != ShapeRelation.INTERSECTS) {
187+
throw new IllegalArgumentException("current strategy [" + strategy.getStrategyName() + "] only supports relation ["
188+
+ ShapeRelation.INTERSECTS.getRelationName() + "] found relation [" + relation.getRelationName() + "]");
189+
}
190+
this.relation = relation;
191+
return this;
192+
}
193+
176194
/**
177195
* Defines which spatial strategy will be used for building the geo shape
178196
* Query. When not set, the strategy that will be used will be the one that

0 commit comments

Comments
 (0)