|
13 | 13 | import org.elasticsearch.geo.GeometryTestUtils; |
14 | 14 | import org.elasticsearch.geometry.Geometry; |
15 | 15 | import org.elasticsearch.geometry.ShapeType; |
| 16 | +import org.elasticsearch.index.IndexVersions; |
16 | 17 | import org.elasticsearch.index.mapper.MapperService; |
17 | 18 | import org.elasticsearch.index.query.GeoShapeQueryBuilder; |
18 | 19 | import org.elasticsearch.index.query.SearchExecutionContext; |
@@ -87,15 +88,27 @@ protected GeoShapeQueryBuilder doCreateTestQueryBuilder(boolean indexedShape) { |
87 | 88 | } |
88 | 89 | if (ESTestCase.randomBoolean()) { |
89 | 90 | SearchExecutionContext context = AbstractBuilderTestCase.createSearchExecutionContext(); |
90 | | - if (shapeType == ShapeType.LINESTRING || shapeType == ShapeType.MULTILINESTRING) { |
91 | | - builder.relation(ESTestCase.randomFrom(ShapeRelation.DISJOINT, ShapeRelation.INTERSECTS, ShapeRelation.CONTAINS)); |
| 91 | + if (context.indexVersionCreated().onOrAfter(IndexVersions.V_7_5_0)) { // CONTAINS is only supported from version 7.5 |
| 92 | + if (shapeType == ShapeType.LINESTRING || shapeType == ShapeType.MULTILINESTRING) { |
| 93 | + builder.relation(ESTestCase.randomFrom(ShapeRelation.DISJOINT, ShapeRelation.INTERSECTS, ShapeRelation.CONTAINS)); |
| 94 | + } else { |
| 95 | + builder.relation( |
| 96 | + ESTestCase.randomFrom( |
| 97 | + ShapeRelation.DISJOINT, |
| 98 | + ShapeRelation.INTERSECTS, |
| 99 | + ShapeRelation.WITHIN, |
| 100 | + ShapeRelation.CONTAINS |
| 101 | + ) |
| 102 | + ); |
| 103 | + } |
92 | 104 | } else { |
93 | | - builder.relation( |
94 | | - ESTestCase.randomFrom(ShapeRelation.DISJOINT, ShapeRelation.INTERSECTS, ShapeRelation.WITHIN, ShapeRelation.CONTAINS) |
95 | | - ); |
| 105 | + if (shapeType == ShapeType.LINESTRING || shapeType == ShapeType.MULTILINESTRING) { |
| 106 | + builder.relation(ESTestCase.randomFrom(ShapeRelation.DISJOINT, ShapeRelation.INTERSECTS)); |
| 107 | + } else { |
| 108 | + builder.relation(ESTestCase.randomFrom(ShapeRelation.DISJOINT, ShapeRelation.INTERSECTS, ShapeRelation.WITHIN)); |
| 109 | + } |
96 | 110 | } |
97 | 111 | } |
98 | | - |
99 | 112 | if (ESTestCase.randomBoolean()) { |
100 | 113 | builder.ignoreUnmapped(ESTestCase.randomBoolean()); |
101 | 114 | } |
|
0 commit comments