Another test for parsing "geo_distance" filter: 12mi and km
If an explicit unit is provided with "distance", the "unit" can be safely ignored, as it works as a fallback unit.
This commit is contained in:
parent
8c8b7bee3a
commit
2d15cd8009
|
@ -1311,6 +1311,19 @@ public class SimpleIndexQueryParserTests {
|
|||
assertThat(filter.distance(), closeTo(12, 0.00001));
|
||||
}
|
||||
|
||||
@Test public void testGeoDistanceFilter12() throws IOException {
|
||||
IndexQueryParser queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/xcontent/geo_distance12.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(FilteredQuery.class));
|
||||
FilteredQuery filteredQuery = (FilteredQuery) parsedQuery;
|
||||
GeoDistanceFilter filter = (GeoDistanceFilter) filteredQuery.getFilter();
|
||||
assertThat(filter.fieldName(), equalTo("location"));
|
||||
assertThat(filter.lat(), closeTo(40, 0.00001));
|
||||
assertThat(filter.lon(), closeTo(-70, 0.00001));
|
||||
assertThat(filter.distance(), closeTo(12, 0.00001));
|
||||
}
|
||||
|
||||
@Test public void testGeoBoundingBoxFilterNamed() throws IOException {
|
||||
IndexQueryParser queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/xcontent/geo_boundingbox-named.json");
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"filtered" : {
|
||||
"query" : {
|
||||
"match_all" : {}
|
||||
},
|
||||
"filter" : {
|
||||
"geo_distance" : {
|
||||
"distance" : "12mi",
|
||||
"unit": "km",
|
||||
"person.location" : {
|
||||
"lat" : 40,
|
||||
"lon" : -70
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue