33
33
import org .elasticsearch .index .query .QueryBuilders ;
34
34
import org .elasticsearch .test .ESSingleNodeTestCase ;
35
35
import org .elasticsearch .test .geo .RandomShapeGenerator ;
36
- import org .junit .Test ;
37
36
38
37
import java .io .IOException ;
39
38
import java .util .Locale ;
@@ -64,7 +63,6 @@ public void testNullShape() throws Exception {
64
63
assertThat (result .getField ("location" ), nullValue ());
65
64
}
66
65
67
- @ Test
68
66
public void testIndexPointsFilterRectangle () throws Exception {
69
67
String mapping = XContentFactory .jsonBuilder ().startObject ().startObject ("type1" )
70
68
.startObject ("properties" ).startObject ("location" )
@@ -112,9 +110,7 @@ public void testIndexPointsFilterRectangle() throws Exception {
112
110
assertThat (searchResponse .getHits ().getAt (0 ).id (), equalTo ("1" ));
113
111
}
114
112
115
- @ Test
116
113
public void testEdgeCases () throws Exception {
117
-
118
114
String mapping = XContentFactory .jsonBuilder ().startObject ().startObject ("type1" )
119
115
.startObject ("properties" ).startObject ("location" )
120
116
.field ("type" , "geo_shape" )
@@ -150,7 +146,6 @@ public void testEdgeCases() throws Exception {
150
146
assertThat (searchResponse .getHits ().getAt (0 ).id (), equalTo ("blakely" ));
151
147
}
152
148
153
- @ Test
154
149
public void testIndexedShapeReference () throws Exception {
155
150
String mapping = XContentFactory .jsonBuilder ().startObject ().startObject ("type1" )
156
151
.startObject ("properties" ).startObject ("location" )
@@ -175,7 +170,8 @@ public void testIndexedShapeReference() throws Exception {
175
170
.endObject ()).setRefresh (true ).execute ().actionGet ();
176
171
177
172
SearchResponse searchResponse = client ().prepareSearch ("test" ).setTypes ("type1" )
178
- .setQuery (geoIntersectionQuery ("location" , "Big_Rectangle" , "shape_type" )).execute ().actionGet ();
173
+ .setQuery (geoIntersectionQuery ("location" , "Big_Rectangle" , "shape_type" ))
174
+ .execute ().actionGet ();
179
175
180
176
assertSearchResponse (searchResponse );
181
177
assertThat (searchResponse .getHits ().getTotalHits (), equalTo (1l ));
@@ -192,7 +188,6 @@ public void testIndexedShapeReference() throws Exception {
192
188
assertThat (searchResponse .getHits ().getAt (0 ).id (), equalTo ("1" ));
193
189
}
194
190
195
- @ Test
196
191
public void testReusableBuilder () throws IOException {
197
192
ShapeBuilder polygon = ShapeBuilder .newPolygon ()
198
193
.point (170 , -10 ).point (190 , -10 ).point (190 , 10 ).point (170 , 10 )
@@ -212,44 +207,6 @@ private void assertUnmodified(ShapeBuilder builder) throws IOException {
212
207
assertThat (before , equalTo (after ));
213
208
}
214
209
215
- @ Test
216
- public void testParsingMultipleShapes () throws Exception {
217
- String mapping = XContentFactory .jsonBuilder ()
218
- .startObject ()
219
- .startObject ("type1" )
220
- .startObject ("properties" )
221
- .startObject ("location1" )
222
- .field ("type" , "geo_shape" )
223
- .endObject ()
224
- .startObject ("location2" )
225
- .field ("type" , "geo_shape" )
226
- .endObject ()
227
- .endObject ()
228
- .endObject ()
229
- .endObject ()
230
- .string ();
231
-
232
- client ().admin ().indices ().prepareCreate ("test" ).addMapping ("type1" , mapping ).execute ().actionGet ();
233
-
234
- String p1 = "\" location1\" : {\" type\" :\" polygon\" , \" coordinates\" :[[[-10,-10],[10,-10],[10,10],[-10,10],[-10,-10]]]}" ;
235
- String p2 = "\" location2\" : {\" type\" :\" polygon\" , \" coordinates\" :[[[-20,-20],[20,-20],[20,20],[-20,20],[-20,-20]]]}" ;
236
- String o1 = "{" + p1 + ", " + p2 + "}" ;
237
-
238
- client ().prepareIndex ("test" , "type1" , "1" ).setSource (o1 ).setRefresh (true ).execute ().actionGet ();
239
-
240
- String filter = "{\" geo_shape\" : {\" location2\" : {\" indexed_shape\" : {"
241
- + "\" id\" : \" 1\" ,"
242
- + "\" type\" : \" type1\" ,"
243
- + "\" index\" : \" test\" ,"
244
- + "\" path\" : \" location2\" "
245
- + "}}}}" ;
246
-
247
- SearchResponse result = client ().prepareSearch ("test" ).setTypes ("type1" ).setQuery (QueryBuilders .matchAllQuery ()).setPostFilter (filter ).execute ().actionGet ();
248
- assertSearchResponse (result );
249
- assertHitCount (result , 1 );
250
- }
251
-
252
- @ Test
253
210
public void testShapeFetchingPath () throws Exception {
254
211
createIndex ("shapes" );
255
212
client ().admin ().indices ().prepareCreate ("test" ).addMapping ("type" , "location" , "type=geo_shape" ).execute ().actionGet ();
@@ -274,28 +231,28 @@ public void testShapeFetchingPath() throws Exception {
274
231
.endArray ().endArray ()
275
232
.endObject ().endObject ()).setRefresh (true ).execute ().actionGet ();
276
233
277
- GeoShapeQueryBuilder filter = QueryBuilders .geoShapeQuery ("location" , "1" , "type" , ShapeRelation .INTERSECTS )
234
+ GeoShapeQueryBuilder filter = QueryBuilders .geoShapeQuery ("location" , "1" , "type" ). relation ( ShapeRelation .INTERSECTS )
278
235
.indexedShapeIndex ("shapes" )
279
236
.indexedShapePath ("location" );
280
237
SearchResponse result = client ().prepareSearch ("test" ).setQuery (QueryBuilders .matchAllQuery ())
281
238
.setPostFilter (filter ).get ();
282
239
assertSearchResponse (result );
283
240
assertHitCount (result , 1 );
284
- filter = QueryBuilders .geoShapeQuery ("location" , "1" , "type" , ShapeRelation .INTERSECTS )
241
+ filter = QueryBuilders .geoShapeQuery ("location" , "1" , "type" ). relation ( ShapeRelation .INTERSECTS )
285
242
.indexedShapeIndex ("shapes" )
286
243
.indexedShapePath ("1.location" );
287
244
result = client ().prepareSearch ("test" ).setQuery (QueryBuilders .matchAllQuery ())
288
245
.setPostFilter (filter ).get ();
289
246
assertSearchResponse (result );
290
247
assertHitCount (result , 1 );
291
- filter = QueryBuilders .geoShapeQuery ("location" , "1" , "type" , ShapeRelation .INTERSECTS )
248
+ filter = QueryBuilders .geoShapeQuery ("location" , "1" , "type" ). relation ( ShapeRelation .INTERSECTS )
292
249
.indexedShapeIndex ("shapes" )
293
250
.indexedShapePath ("1.2.location" );
294
251
result = client ().prepareSearch ("test" ).setQuery (QueryBuilders .matchAllQuery ())
295
252
.setPostFilter (filter ).get ();
296
253
assertSearchResponse (result );
297
254
assertHitCount (result , 1 );
298
- filter = QueryBuilders .geoShapeQuery ("location" , "1" , "type" , ShapeRelation .INTERSECTS )
255
+ filter = QueryBuilders .geoShapeQuery ("location" , "1" , "type" ). relation ( ShapeRelation .INTERSECTS )
299
256
.indexedShapeIndex ("shapes" )
300
257
.indexedShapePath ("1.2.3.location" );
301
258
result = client ().prepareSearch ("test" ).setQuery (QueryBuilders .matchAllQuery ())
0 commit comments