@@ -158,7 +158,7 @@ public void testParsingAndToQuery1() throws IOException {
158
158
" }\n " +
159
159
" }\n " +
160
160
"}\n " ;
161
- assertGeoDistanceRangeQuery (query , 40 , -70 , 12 , DistanceUnit .DEFAULT );
161
+ assertGeoDistanceRangeQuery (query , 40 , -70 , 12 , DistanceUnit .MILES );
162
162
}
163
163
164
164
public void testParsingAndToQuery2 () throws IOException {
@@ -169,7 +169,7 @@ public void testParsingAndToQuery2() throws IOException {
169
169
" \" " + GEO_POINT_FIELD_NAME + "\" :[-70, 40]\n " +
170
170
" }\n " +
171
171
"}\n " ;
172
- assertGeoDistanceRangeQuery (query , 40 , -70 , 12 , DistanceUnit .DEFAULT );
172
+ assertGeoDistanceRangeQuery (query , 40 , -70 , 12 , DistanceUnit .MILES );
173
173
}
174
174
175
175
public void testParsingAndToQuery3 () throws IOException {
@@ -180,7 +180,7 @@ public void testParsingAndToQuery3() throws IOException {
180
180
" \" " + GEO_POINT_FIELD_NAME + "\" :\" 40, -70\" \n " +
181
181
" }\n " +
182
182
"}\n " ;
183
- assertGeoDistanceRangeQuery (query , 40 , -70 , 12 , DistanceUnit .DEFAULT );
183
+ assertGeoDistanceRangeQuery (query , 40 , -70 , 12 , DistanceUnit .MILES );
184
184
}
185
185
186
186
public void testParsingAndToQuery4 () throws IOException {
@@ -191,7 +191,8 @@ public void testParsingAndToQuery4() throws IOException {
191
191
" \" " + GEO_POINT_FIELD_NAME + "\" :\" drn5x1g8cu2y\" \n " +
192
192
" }\n " +
193
193
"}\n " ;
194
- assertGeoDistanceRangeQuery (query , 40 , -70 , 12 , DistanceUnit .DEFAULT );
194
+ GeoPoint geoPoint = GeoPoint .fromGeohash ("drn5x1g8cu2y" );
195
+ assertGeoDistanceRangeQuery (query , geoPoint .getLat (), geoPoint .getLon (), 12 , DistanceUnit .MILES );
195
196
}
196
197
197
198
public void testParsingAndToQuery5 () throws IOException {
@@ -206,7 +207,7 @@ public void testParsingAndToQuery5() throws IOException {
206
207
" }\n " +
207
208
" }\n " +
208
209
"}\n " ;
209
- assertGeoDistanceRangeQuery (query , 40 , -70 , 12 , DistanceUnit .DEFAULT );
210
+ assertGeoDistanceRangeQuery (query , 40 , -70 , 12 , DistanceUnit .MILES );
210
211
}
211
212
212
213
public void testParsingAndToQuery6 () throws IOException {
@@ -221,7 +222,7 @@ public void testParsingAndToQuery6() throws IOException {
221
222
" }\n " +
222
223
" }\n " +
223
224
"}\n " ;
224
- assertGeoDistanceRangeQuery (query , 40 , -70 , 12 , DistanceUnit .DEFAULT );
225
+ assertGeoDistanceRangeQuery (query , 40 , -70 , 12 , DistanceUnit .MILES );
225
226
}
226
227
227
228
public void testParsingAndToQuery7 () throws IOException {
@@ -235,7 +236,7 @@ public void testParsingAndToQuery7() throws IOException {
235
236
" }\n " +
236
237
" }\n " +
237
238
"}\n " ;
238
- assertGeoDistanceRangeQuery (query , 40 , -70 , 0.012 , DistanceUnit .DEFAULT );
239
+ assertGeoDistanceRangeQuery (query , 40 , -70 , 19.312128 , DistanceUnit .DEFAULT );
239
240
}
240
241
241
242
public void testParsingAndToQuery8 () throws IOException {
@@ -249,7 +250,7 @@ public void testParsingAndToQuery8() throws IOException {
249
250
" }\n " +
250
251
" }\n " +
251
252
"}\n " ;
252
- assertGeoDistanceRangeQuery (query , 40 , -70 , 12 , DistanceUnit .KILOMETERS );
253
+ assertGeoDistanceRangeQuery (query , 40 , -70 , 19.312128 , DistanceUnit .DEFAULT );
253
254
}
254
255
255
256
public void testParsingAndToQuery9 () throws IOException {
@@ -264,7 +265,7 @@ public void testParsingAndToQuery9() throws IOException {
264
265
" }\n " +
265
266
" }\n " +
266
267
"}\n " ;
267
- assertGeoDistanceRangeQuery (query , 40 , -70 , 12 , DistanceUnit .DEFAULT );
268
+ assertGeoDistanceRangeQuery (query , 40 , -70 , 19.312128 , DistanceUnit .KILOMETERS );
268
269
}
269
270
270
271
public void testParsingAndToQuery10 () throws IOException {
@@ -279,7 +280,7 @@ public void testParsingAndToQuery10() throws IOException {
279
280
" }\n " +
280
281
" }\n " +
281
282
"}\n " ;
282
- assertGeoDistanceRangeQuery (query , 40 , -70 , 12 , DistanceUnit .DEFAULT );
283
+ assertGeoDistanceRangeQuery (query , 40 , -70 , 19.312128 , DistanceUnit .KILOMETERS );
283
284
}
284
285
285
286
public void testParsingAndToQuery11 () throws IOException {
@@ -293,7 +294,7 @@ public void testParsingAndToQuery11() throws IOException {
293
294
" }\n " +
294
295
" }\n " +
295
296
"}\n " ;
296
- assertGeoDistanceRangeQuery (query , 40 , -70 , 12 , DistanceUnit .DEFAULT );
297
+ assertGeoDistanceRangeQuery (query , 40 , -70 , 19.312128 , DistanceUnit .KILOMETERS );
297
298
}
298
299
299
300
public void testParsingAndToQuery12 () throws IOException {
@@ -308,13 +309,17 @@ public void testParsingAndToQuery12() throws IOException {
308
309
" }\n " +
309
310
" }\n " +
310
311
"}\n " ;
311
- assertGeoDistanceRangeQuery (query , 40 , -70 , 12 , DistanceUnit .DEFAULT );
312
+ assertGeoDistanceRangeQuery (query , 40 , -70 , 12 , DistanceUnit .MILES );
312
313
}
313
314
314
- private void assertGeoDistanceRangeQuery (String query , double lat , double lon , double distance , DistanceUnit distanceUnit ) throws IOException {
315
+ private void assertGeoDistanceRangeQuery (String query , double lat , double lon , double distance , DistanceUnit distanceUnit )
316
+ throws IOException {
315
317
assumeTrue ("test runs only when at least a type is registered" , getCurrentTypes ().length > 0 );
316
318
Query parsedQuery = parseQuery (query ).toQuery (createShardContext ());
317
- // TODO: what can we check?
319
+ // The parsedQuery contains IndexOrDocValuesQuery, which wraps LatLonPointDistanceQuery which in turn has default visibility,
320
+ // so we cannot access its fields directly to check and have to use toString() here instead.
321
+ assertEquals (parsedQuery .toString (),
322
+ "mapped_geo_point:" + lat + "," + lon + " +/- " + distanceUnit .toMeters (distance ) + " meters" );
318
323
}
319
324
320
325
public void testFromJson () throws IOException {
0 commit comments