diff --git a/modules/elasticsearch/src/test/java/org/elasticsearch/index/query/xcontent/SimpleIndexQueryParserTests.java b/modules/elasticsearch/src/test/java/org/elasticsearch/index/query/xcontent/SimpleIndexQueryParserTests.java index 17fd52ad41e..0691a3a2433 100644 --- a/modules/elasticsearch/src/test/java/org/elasticsearch/index/query/xcontent/SimpleIndexQueryParserTests.java +++ b/modules/elasticsearch/src/test/java/org/elasticsearch/index/query/xcontent/SimpleIndexQueryParserTests.java @@ -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"); diff --git a/modules/elasticsearch/src/test/java/org/elasticsearch/index/query/xcontent/geo_distance12.json b/modules/elasticsearch/src/test/java/org/elasticsearch/index/query/xcontent/geo_distance12.json new file mode 100644 index 00000000000..909c4b537b7 --- /dev/null +++ b/modules/elasticsearch/src/test/java/org/elasticsearch/index/query/xcontent/geo_distance12.json @@ -0,0 +1,17 @@ +{ + "filtered" : { + "query" : { + "match_all" : {} + }, + "filter" : { + "geo_distance" : { + "distance" : "12mi", + "unit": "km", + "person.location" : { + "lat" : 40, + "lon" : -70 + } + } + } + } +}