Skip to content

Commit 0cd36c5

Browse files
committed
rebase old PR to master. initial round of updates
1 parent 9bbf5c0 commit 0cd36c5

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,7 @@ protected static List<List<List<GeoPoint>>> parseMultiPolygon(XContentParser par
294294
return polygons;
295295
}
296296

297-
public static GeoPolygonQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException {
298-
XContentParser parser = parseContext.parser();
297+
public static GeoPolygonQueryBuilder fromXContent(XContentParser parser) throws IOException {
299298
String fieldName = null;
300299

301300
List shell = null;
@@ -322,7 +321,7 @@ public static GeoPolygonQueryBuilder fromXContent(QueryParseContext parseContext
322321
while ((token = parser.nextToken()) != Token.END_ARRAY) {
323322
shell.add(GeoUtils.parseGeoPoint(parser));
324323
}
325-
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, MULTIPOLYGON_FIELD)) {
324+
} else if (MULTIPOLYGON_FIELD.match(currentFieldName, parser.getDeprecationHandler())) {
326325
// parse a multipolygon as defined in the GeoJSON spec
327326
// Note: shape validation is not performed, possible todo but perhaps overkill
328327
shell = parseMultiPolygon(parser);

server/src/test/java/org/elasticsearch/index/query/GeoPolygonQueryBuilderTests.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,31 @@ public void testParsingAndToQuery4() throws IOException {
196196
}
197197

198198
public void testParsingAndToQuery5() throws IOException {
199-
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
200199
String query = "{\n" +
201200
" \"geo_polygon\":{\n" +
202201
" \"" + GEO_POINT_FIELD_NAME + "\":{\n" +
203-
" \"multipolygon\":[ [ [\n" +
204-
" [-70, 40],\n" +
205-
" [-80, 30],\n" +
206-
" [-90, 20]\n" +
207-
" ] ] ]\n" +
202+
" \"multipolygon\":[\n" +
203+
" [\n" +
204+
" [[-70, 40],\n" +
205+
" [-80, 30],\n" +
206+
" [-90, 20]]\n" +
207+
" ],\n" +
208+
" [\n" +
209+
" [[70, 40],\n" +
210+
" [80, 30],\n" +
211+
" [90, 20]]\n" +
212+
" ],\n" +
213+
" [\n" +
214+
" [[-10, -10],\n" +
215+
" [10, -10],\n" +
216+
" [10, 10],\n" +
217+
" [-10, 10]],\n" +
218+
" [[-5, -5],\n" +
219+
" [5, -5],\n" +
220+
" [5, 5],\n" +
221+
" [-5, 5]]\n" +
222+
" ]\n" +
223+
" ]\n" +
208224
" }\n" +
209225
" }\n" +
210226
"}\n";

0 commit comments

Comments
 (0)