53
53
public class GeoPolygonFilterParser implements FilterParser {
54
54
55
55
public static final String NAME = "geo_polygon" ;
56
- public static final String POINTS = "points" ;
56
+ public static final String POINTS = "points" ;
57
57
58
58
@ Inject
59
59
public GeoPolygonFilterParser () {
@@ -91,13 +91,15 @@ public Filter parse(QueryParseContext parseContext) throws IOException, QueryPar
91
91
if (token == XContentParser .Token .FIELD_NAME ) {
92
92
currentFieldName = parser .currentName ();
93
93
} else if (token == XContentParser .Token .START_ARRAY ) {
94
- if (POINTS .equals (currentFieldName )) {
95
- while ((token = parser .nextToken ()) != Token .END_ARRAY ) {
94
+ if (POINTS .equals (currentFieldName )) {
95
+ while ((token = parser .nextToken ()) != Token .END_ARRAY ) {
96
96
shell .add (GeoPoint .parse (parser ));
97
97
}
98
98
} else {
99
99
throw new QueryParsingException (parseContext .index (), "[geo_polygon] filter does not support [" + currentFieldName + "]" );
100
100
}
101
+ } else {
102
+ throw new QueryParsingException (parseContext .index (), "[geo_polygon] filter does not support token type [" + token .name () + "] under [" + currentFieldName + "]" );
101
103
}
102
104
}
103
105
} else if (token .isValue ()) {
@@ -113,20 +115,22 @@ public Filter parse(QueryParseContext parseContext) throws IOException, QueryPar
113
115
} else {
114
116
throw new QueryParsingException (parseContext .index (), "[geo_polygon] filter does not support [" + currentFieldName + "]" );
115
117
}
118
+ } else {
119
+ throw new QueryParsingException (parseContext .index (), "[geo_polygon] unexpected token type [" + token .name () + "]" );
116
120
}
117
121
}
118
122
119
123
if (shell .isEmpty ()) {
120
124
throw new QueryParsingException (parseContext .index (), "no points defined for geo_polygon filter" );
121
125
} else {
122
- if (shell .size () < 3 ) {
126
+ if (shell .size () < 3 ) {
123
127
throw new QueryParsingException (parseContext .index (), "to few points defined for geo_polygon filter" );
124
128
}
125
129
GeoPoint start = shell .get (0 );
126
- if (!start .equals (shell .get (shell .size ()- 1 ))) {
130
+ if (!start .equals (shell .get (shell .size () - 1 ))) {
127
131
shell .add (start );
128
132
}
129
- if (shell .size () < 4 ) {
133
+ if (shell .size () < 4 ) {
130
134
throw new QueryParsingException (parseContext .index (), "to few points defined for geo_polygon filter" );
131
135
}
132
136
}
0 commit comments