|
23 | 23 | import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
|
24 | 24 | import org.elasticsearch.common.Strings;
|
25 | 25 | import org.elasticsearch.common.geo.builders.ShapeBuilder;
|
| 26 | +import org.elasticsearch.common.xcontent.ToXContent; |
26 | 27 | import org.elasticsearch.common.xcontent.XContentFactory;
|
27 | 28 | import org.elasticsearch.common.xcontent.XContentType;
|
| 29 | +import org.elasticsearch.geometry.Circle; |
28 | 30 | import org.elasticsearch.index.IndexService;
|
29 | 31 | import org.elasticsearch.index.mapper.LegacyGeoShapeFieldMapper;
|
30 | 32 | import org.elasticsearch.index.mapper.MappedFieldType;
|
@@ -161,6 +163,29 @@ public void testIndexShapeRouting() throws Exception {
|
161 | 163 | assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
|
162 | 164 | }
|
163 | 165 |
|
| 166 | + /** |
| 167 | + * Test that the circle is still supported for the legacy shapes |
| 168 | + */ |
| 169 | + public void testLegacyCircle() throws Exception { |
| 170 | + // create index |
| 171 | + assertAcked(client().admin().indices().prepareCreate("test") |
| 172 | + .addMapping("geometry", "shape", "type=geo_shape,strategy=recursive,tree=geohash").get()); |
| 173 | + ensureGreen(); |
| 174 | + |
| 175 | + indexRandom(true, client().prepareIndex("test").setId("0").setSource("shape", (ToXContent) (builder, params) -> { |
| 176 | + builder.startObject().field("type", "circle") |
| 177 | + .startArray("coordinates").value(30).value(50).endArray() |
| 178 | + .field("radius","77km") |
| 179 | + .endObject(); |
| 180 | + return builder; |
| 181 | + })); |
| 182 | + |
| 183 | + // test self crossing of circles |
| 184 | + SearchResponse searchResponse = client().prepareSearch("test").setQuery(geoShapeQuery("shape", |
| 185 | + new Circle(30, 50, 77000))).get(); |
| 186 | + assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L)); |
| 187 | + } |
| 188 | + |
164 | 189 | private String findNodeName(String index) {
|
165 | 190 | ClusterState state = client().admin().cluster().prepareState().get().getState();
|
166 | 191 | IndexShardRoutingTable shard = state.getRoutingTable().index(index).shard(0);
|
|
0 commit comments