Browse Source

Remove explicit SearchResponse references from server geo (#101758)

Ignacio Vera 1 year ago
parent
commit
a3319440a6

+ 79 - 62
server/src/internalClusterTest/java/org/elasticsearch/search/geo/GeoDistanceIT.java

@@ -8,8 +8,6 @@
 
 package org.elasticsearch.search.geo;
 
-import org.elasticsearch.action.search.SearchRequestBuilder;
-import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.cluster.metadata.IndexMetadata;
 import org.elasticsearch.common.geo.GeoPoint;
 import org.elasticsearch.common.geo.GeoUtils;
@@ -42,6 +40,7 @@ import java.util.Map;
 import java.util.function.Function;
 
 import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertResponse;
 import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder;
 import static org.hamcrest.Matchers.closeTo;
 
@@ -126,51 +125,69 @@ public class GeoDistanceIT extends ESIntegTestCase {
         refresh();
 
         // Test doc['location'].arcDistance(lat, lon)
-        SearchResponse searchResponse1 = prepareSearch().addStoredField("_source")
-            .addScriptField("distance", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "arcDistance", Collections.emptyMap()))
-            .get();
-        Double resultDistance1 = searchResponse1.getHits().getHits()[0].getFields().get("distance").getValue();
-        assertThat(resultDistance1, closeTo(GeoUtils.arcDistance(src_lat, src_lon, tgt_lat, tgt_lon), 0.01d));
-
+        assertResponse(
+            prepareSearch().addStoredField("_source")
+                .addScriptField("distance", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "arcDistance", Collections.emptyMap())),
+            response -> {
+                Double resultDistance = response.getHits().getHits()[0].getFields().get("distance").getValue();
+                assertThat(resultDistance, closeTo(GeoUtils.arcDistance(src_lat, src_lon, tgt_lat, tgt_lon), 0.01d));
+            }
+        );
         // Test doc['location'].planeDistance(lat, lon)
-        SearchResponse searchResponse2 = prepareSearch().addStoredField("_source")
-            .addScriptField("distance", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "planeDistance", Collections.emptyMap()))
-            .get();
-        Double resultDistance2 = searchResponse2.getHits().getHits()[0].getFields().get("distance").getValue();
-        assertThat(resultDistance2, closeTo(GeoUtils.planeDistance(src_lat, src_lon, tgt_lat, tgt_lon), 0.01d));
-
+        assertResponse(
+            prepareSearch().addStoredField("_source")
+                .addScriptField(
+                    "distance",
+                    new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "planeDistance", Collections.emptyMap())
+                ),
+            response -> {
+                Double resultDistance = response.getHits().getHits()[0].getFields().get("distance").getValue();
+                assertThat(resultDistance, closeTo(GeoUtils.planeDistance(src_lat, src_lon, tgt_lat, tgt_lon), 0.01d));
+            }
+        );
         // Test doc['location'].geohashDistance(lat, lon)
-        SearchResponse searchResponse4 = prepareSearch().addStoredField("_source")
-            .addScriptField("distance", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "geohashDistance", Collections.emptyMap()))
-            .get();
-        Double resultDistance4 = searchResponse4.getHits().getHits()[0].getFields().get("distance").getValue();
-        assertThat(
-            resultDistance4,
-            closeTo(
-                GeoUtils.arcDistance(src_lat, src_lon, Geohash.decodeLatitude(tgt_geohash), Geohash.decodeLongitude(tgt_geohash)),
-                0.01d
-            )
+        assertResponse(
+            prepareSearch().addStoredField("_source")
+                .addScriptField(
+                    "distance",
+                    new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "geohashDistance", Collections.emptyMap())
+                ),
+            response -> {
+                Double resultDistance = response.getHits().getHits()[0].getFields().get("distance").getValue();
+                assertThat(
+                    resultDistance,
+                    closeTo(
+                        GeoUtils.arcDistance(src_lat, src_lon, Geohash.decodeLatitude(tgt_geohash), Geohash.decodeLongitude(tgt_geohash)),
+                        0.01d
+                    )
+                );
+            }
         );
 
         // Test doc['location'].arcDistance(lat, lon + 360)/1000d
-        SearchResponse searchResponse5 = prepareSearch().addStoredField("_source")
-            .addScriptField(
-                "distance",
-                new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "arcDistance(lat, lon + 360)/1000d", Collections.emptyMap())
-            )
-            .get();
-        Double resultArcDistance5 = searchResponse5.getHits().getHits()[0].getFields().get("distance").getValue();
-        assertThat(resultArcDistance5, closeTo(GeoUtils.arcDistance(src_lat, src_lon, tgt_lat, tgt_lon) / 1000d, 0.01d));
-
+        assertResponse(
+            prepareSearch().addStoredField("_source")
+                .addScriptField(
+                    "distance",
+                    new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "arcDistance(lat, lon + 360)/1000d", Collections.emptyMap())
+                ),
+            response -> {
+                Double resultArcDistance = response.getHits().getHits()[0].getFields().get("distance").getValue();
+                assertThat(resultArcDistance, closeTo(GeoUtils.arcDistance(src_lat, src_lon, tgt_lat, tgt_lon) / 1000d, 0.01d));
+            }
+        );
         // Test doc['location'].arcDistance(lat + 360, lon)/1000d
-        SearchResponse searchResponse6 = prepareSearch().addStoredField("_source")
-            .addScriptField(
-                "distance",
-                new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "arcDistance(lat + 360, lon)/1000d", Collections.emptyMap())
-            )
-            .get();
-        Double resultArcDistance6 = searchResponse6.getHits().getHits()[0].getFields().get("distance").getValue();
-        assertThat(resultArcDistance6, closeTo(GeoUtils.arcDistance(src_lat, src_lon, tgt_lat, tgt_lon) / 1000d, 0.01d));
+        assertResponse(
+            prepareSearch().addStoredField("_source")
+                .addScriptField(
+                    "distance",
+                    new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "arcDistance(lat + 360, lon)/1000d", Collections.emptyMap())
+                ),
+            response -> {
+                Double resultArcDistance = response.getHits().getHits()[0].getFields().get("distance").getValue();
+                assertThat(resultArcDistance, closeTo(GeoUtils.arcDistance(src_lat, src_lon, tgt_lat, tgt_lon) / 1000d, 0.01d));
+            }
+        );
     }
 
     public void testGeoDistanceAggregation() throws IOException {
@@ -189,28 +206,28 @@ public class GeoDistanceIT extends ESIntegTestCase {
 
         refresh();
 
-        SearchRequestBuilder search = prepareSearch("test");
         String name = "TestPosition";
 
-        search.setQuery(QueryBuilders.matchAllQuery())
-            .addAggregation(
-                AggregationBuilders.geoDistance(name, new GeoPoint(tgt_lat, tgt_lon))
-                    .field("location")
-                    .unit(DistanceUnit.MILES)
-                    .addRange(0, 25000)
-            );
-
-        search.setSize(0); // no hits please
-
-        SearchResponse response = search.get();
-        Aggregations aggregations = response.getAggregations();
-        assertNotNull(aggregations);
-        InternalGeoDistance geoDistance = aggregations.get(name);
-        assertNotNull(geoDistance);
-
-        List<? extends Range.Bucket> buckets = ((Range) geoDistance).getBuckets();
-        assertNotNull("Buckets should not be null", buckets);
-        assertEquals("Unexpected number of buckets", 1, buckets.size());
-        assertEquals("Unexpected doc count for geo distance", 1, buckets.get(0).getDocCount());
+        assertResponse(
+            prepareSearch("test").setQuery(QueryBuilders.matchAllQuery())
+                .setSize(0) // no hits please
+                .addAggregation(
+                    AggregationBuilders.geoDistance(name, new GeoPoint(tgt_lat, tgt_lon))
+                        .field("location")
+                        .unit(DistanceUnit.MILES)
+                        .addRange(0, 25000)
+                ),
+            response -> {
+                Aggregations aggregations = response.getAggregations();
+                assertNotNull(aggregations);
+                InternalGeoDistance geoDistance = aggregations.get(name);
+                assertNotNull(geoDistance);
+
+                List<? extends Range.Bucket> buckets = ((Range) geoDistance).getBuckets();
+                assertNotNull("Buckets should not be null", buckets);
+                assertEquals("Unexpected number of buckets", 1, buckets.size());
+                assertEquals("Unexpected doc count for geo distance", 1, buckets.get(0).getDocCount());
+            }
+        );
     }
 }

+ 72 - 71
server/src/internalClusterTest/java/org/elasticsearch/search/geo/GeoPointScriptDocValuesIT.java

@@ -9,7 +9,6 @@
 package org.elasticsearch.search.geo;
 
 import org.apache.lucene.geo.GeoEncodingUtils;
-import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.common.document.DocumentField;
 import org.elasticsearch.common.geo.BoundingBox;
 import org.elasticsearch.common.geo.GeoPoint;
@@ -36,7 +35,7 @@ import java.util.Map;
 import java.util.function.Function;
 
 import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
-import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailuresAndResponse;
 import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.is;
@@ -154,30 +153,30 @@ public class GeoPointScriptDocValuesIT extends ESSingleNodeTestCase {
             .get();
 
         client().admin().indices().prepareRefresh("test").get();
-
-        SearchResponse searchResponse = client().prepareSearch()
-            .addStoredField("_source")
-            .addScriptField("lat", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "lat", Collections.emptyMap()))
-            .addScriptField("lon", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "lon", Collections.emptyMap()))
-            .addScriptField("height", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "height", Collections.emptyMap()))
-            .addScriptField("width", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "width", Collections.emptyMap()))
-            .addScriptField("label_lat", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "label_lat", Collections.emptyMap()))
-            .addScriptField("label_lon", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "label_lon", Collections.emptyMap()))
-            .get();
-        assertNoFailures(searchResponse);
-
-        final double qLat = GeoEncodingUtils.decodeLatitude(GeoEncodingUtils.encodeLatitude(lat));
-        final double qLon = GeoEncodingUtils.decodeLongitude(GeoEncodingUtils.encodeLongitude(lon));
-
-        Map<String, DocumentField> fields = searchResponse.getHits().getHits()[0].getFields();
-        assertThat(fields.get("lat").getValue(), equalTo(qLat));
-        assertThat(fields.get("lon").getValue(), equalTo(qLon));
-        assertThat(fields.get("height").getValue(), equalTo(0d));
-        assertThat(fields.get("width").getValue(), equalTo(0d));
-
-        // Check label position is the same point
-        assertThat(fields.get("label_lon").getValue(), equalTo(qLon));
-        assertThat(fields.get("label_lat").getValue(), equalTo(qLat));
+        assertNoFailuresAndResponse(
+            client().prepareSearch()
+                .addStoredField("_source")
+                .addScriptField("lat", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "lat", Collections.emptyMap()))
+                .addScriptField("lon", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "lon", Collections.emptyMap()))
+                .addScriptField("height", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "height", Collections.emptyMap()))
+                .addScriptField("width", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "width", Collections.emptyMap()))
+                .addScriptField("label_lat", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "label_lat", Collections.emptyMap()))
+                .addScriptField("label_lon", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "label_lon", Collections.emptyMap())),
+            response -> {
+                final double qLat = GeoEncodingUtils.decodeLatitude(GeoEncodingUtils.encodeLatitude(lat));
+                final double qLon = GeoEncodingUtils.decodeLongitude(GeoEncodingUtils.encodeLongitude(lon));
+
+                Map<String, DocumentField> fields = response.getHits().getHits()[0].getFields();
+                assertThat(fields.get("lat").getValue(), equalTo(qLat));
+                assertThat(fields.get("lon").getValue(), equalTo(qLon));
+                assertThat(fields.get("height").getValue(), equalTo(0d));
+                assertThat(fields.get("width").getValue(), equalTo(0d));
+
+                // Check label position is the same point
+                assertThat(fields.get("label_lon").getValue(), equalTo(qLon));
+                assertThat(fields.get("label_lat").getValue(), equalTo(qLat));
+            }
+        );
     }
 
     public void testRandomMultiPoint() throws Exception {
@@ -199,37 +198,38 @@ public class GeoPointScriptDocValuesIT extends ESSingleNodeTestCase {
 
         client().admin().indices().prepareRefresh("test").get();
 
-        SearchResponse searchResponse = client().prepareSearch()
-            .addStoredField("_source")
-            .addScriptField("lat", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "lat", Collections.emptyMap()))
-            .addScriptField("lon", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "lon", Collections.emptyMap()))
-            .addScriptField("height", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "height", Collections.emptyMap()))
-            .addScriptField("width", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "width", Collections.emptyMap()))
-            .addScriptField("label_lat", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "label_lat", Collections.emptyMap()))
-            .addScriptField("label_lon", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "label_lon", Collections.emptyMap()))
-            .get();
-        assertNoFailures(searchResponse);
-
-        for (int i = 0; i < size; i++) {
-            lats[i] = GeoEncodingUtils.decodeLatitude(GeoEncodingUtils.encodeLatitude(lats[i]));
-            lons[i] = GeoEncodingUtils.decodeLongitude(GeoEncodingUtils.encodeLongitude(lons[i]));
-        }
-
-        final double centroidLon = Arrays.stream(lons).sum() / size;
-        final double centroidLat = Arrays.stream(lats).sum() / size;
-        final double width = Arrays.stream(lons).max().getAsDouble() - Arrays.stream(lons).min().getAsDouble();
-        final double height = Arrays.stream(lats).max().getAsDouble() - Arrays.stream(lats).min().getAsDouble();
-
-        Map<String, DocumentField> fields = searchResponse.getHits().getHits()[0].getFields();
-        assertThat(fields.get("lat").getValue(), equalTo(centroidLat));
-        assertThat(fields.get("lon").getValue(), equalTo(centroidLon));
-        assertThat(fields.get("height").getValue(), equalTo(height));
-        assertThat(fields.get("width").getValue(), equalTo(width));
-
-        // Check label position is one of the incoming points
-        double labelLat = fields.get("label_lat").getValue();
-        double labelLon = fields.get("label_lon").getValue();
-        assertThat("Label should be one of the points", new GeoPoint(labelLat, labelLon), isMultiPointLabelPosition(lats, lons));
+        assertNoFailuresAndResponse(
+            client().prepareSearch()
+                .addStoredField("_source")
+                .addScriptField("lat", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "lat", Collections.emptyMap()))
+                .addScriptField("lon", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "lon", Collections.emptyMap()))
+                .addScriptField("height", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "height", Collections.emptyMap()))
+                .addScriptField("width", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "width", Collections.emptyMap()))
+                .addScriptField("label_lat", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "label_lat", Collections.emptyMap()))
+                .addScriptField("label_lon", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "label_lon", Collections.emptyMap())),
+            response -> {
+                for (int i = 0; i < size; i++) {
+                    lats[i] = GeoEncodingUtils.decodeLatitude(GeoEncodingUtils.encodeLatitude(lats[i]));
+                    lons[i] = GeoEncodingUtils.decodeLongitude(GeoEncodingUtils.encodeLongitude(lons[i]));
+                }
+
+                final double centroidLon = Arrays.stream(lons).sum() / size;
+                final double centroidLat = Arrays.stream(lats).sum() / size;
+                final double width = Arrays.stream(lons).max().getAsDouble() - Arrays.stream(lons).min().getAsDouble();
+                final double height = Arrays.stream(lats).max().getAsDouble() - Arrays.stream(lats).min().getAsDouble();
+
+                Map<String, DocumentField> fields = response.getHits().getHits()[0].getFields();
+                assertThat(fields.get("lat").getValue(), equalTo(centroidLat));
+                assertThat(fields.get("lon").getValue(), equalTo(centroidLon));
+                assertThat(fields.get("height").getValue(), equalTo(height));
+                assertThat(fields.get("width").getValue(), equalTo(width));
+
+                // Check label position is one of the incoming points
+                double labelLat = fields.get("label_lat").getValue();
+                double labelLon = fields.get("label_lon").getValue();
+                assertThat("Label should be one of the points", new GeoPoint(labelLat, labelLon), isMultiPointLabelPosition(lats, lons));
+            }
+        );
     }
 
     public void testNullPoint() throws Exception {
@@ -240,20 +240,21 @@ public class GeoPointScriptDocValuesIT extends ESSingleNodeTestCase {
 
         client().admin().indices().prepareRefresh("test").get();
 
-        SearchResponse searchResponse = client().prepareSearch()
-            .addStoredField("_source")
-            .addScriptField("lat", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "lat", Collections.emptyMap()))
-            .addScriptField("lon", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "lon", Collections.emptyMap()))
-            .addScriptField("height", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "height", Collections.emptyMap()))
-            .addScriptField("width", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "width", Collections.emptyMap()))
-            .get();
-        assertNoFailures(searchResponse);
-
-        Map<String, DocumentField> fields = searchResponse.getHits().getHits()[0].getFields();
-        assertThat(fields.get("lat").getValue(), equalTo(Double.NaN));
-        assertThat(fields.get("lon").getValue(), equalTo(Double.NaN));
-        assertThat(fields.get("height").getValue(), equalTo(Double.NaN));
-        assertThat(fields.get("width").getValue(), equalTo(Double.NaN));
+        assertNoFailuresAndResponse(
+            client().prepareSearch()
+                .addStoredField("_source")
+                .addScriptField("lat", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "lat", Collections.emptyMap()))
+                .addScriptField("lon", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "lon", Collections.emptyMap()))
+                .addScriptField("height", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "height", Collections.emptyMap()))
+                .addScriptField("width", new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "width", Collections.emptyMap())),
+            response -> {
+                Map<String, DocumentField> fields = response.getHits().getHits()[0].getFields();
+                assertThat(fields.get("lat").getValue(), equalTo(Double.NaN));
+                assertThat(fields.get("lon").getValue(), equalTo(Double.NaN));
+                assertThat(fields.get("height").getValue(), equalTo(Double.NaN));
+                assertThat(fields.get("width").getValue(), equalTo(Double.NaN));
+            }
+        );
     }
 
     private static MultiPointLabelPosition isMultiPointLabelPosition(double[] lats, double[] lons) {

+ 24 - 18
server/src/internalClusterTest/java/org/elasticsearch/search/geo/GeoPolygonIT.java

@@ -8,7 +8,6 @@
 
 package org.elasticsearch.search.geo;
 
-import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.cluster.metadata.IndexMetadata;
 import org.elasticsearch.common.geo.GeoPoint;
 import org.elasticsearch.common.settings.Settings;
@@ -24,6 +23,7 @@ import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
 import static org.elasticsearch.index.query.QueryBuilders.geoPolygonQuery;
 import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
 import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
+import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertResponse;
 import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder;
 import static org.hamcrest.Matchers.anyOf;
 import static org.hamcrest.Matchers.equalTo;
@@ -142,14 +142,17 @@ public class GeoPolygonIT extends ESIntegTestCase {
         points.add(new GeoPoint(40.8, -74.1));
         points.add(new GeoPoint(40.8, -74.0));
         points.add(new GeoPoint(40.7, -74.0));
-        SearchResponse searchResponse = prepareSearch("test") // from NY
-            .setQuery(boolQuery().must(geoPolygonQuery("location", points)))
-            .get();
-        assertHitCount(searchResponse, 4);
-        assertThat(searchResponse.getHits().getHits().length, equalTo(4));
-        for (SearchHit hit : searchResponse.getHits()) {
-            assertThat(hit.getId(), anyOf(equalTo("1"), equalTo("3"), equalTo("4"), equalTo("5")));
-        }
+        assertResponse(
+            prepareSearch("test") // from NY
+                .setQuery(boolQuery().must(geoPolygonQuery("location", points))),
+            response -> {
+                assertHitCount(response, 4);
+                assertThat(response.getHits().getHits().length, equalTo(4));
+                for (SearchHit hit : response.getHits()) {
+                    assertThat(hit.getId(), anyOf(equalTo("1"), equalTo("3"), equalTo("4"), equalTo("5")));
+                }
+            }
+        );
     }
 
     public void testSimpleUnclosedPolygon() throws Exception {
@@ -158,14 +161,17 @@ public class GeoPolygonIT extends ESIntegTestCase {
         points.add(new GeoPoint(40.7, -74.1));
         points.add(new GeoPoint(40.8, -74.1));
         points.add(new GeoPoint(40.8, -74.0));
-        SearchResponse searchResponse = prepareSearch("test") // from NY
-            .setQuery(boolQuery().must(geoPolygonQuery("location", points)))
-            .get();
-        assertHitCount(searchResponse, 4);
-        assertThat(searchResponse.getHits().getHits().length, equalTo(4));
-        for (SearchHit hit : searchResponse.getHits()) {
-            assertThat(hit.getId(), anyOf(equalTo("1"), equalTo("3"), equalTo("4"), equalTo("5")));
-        }
+        assertResponse(
+            prepareSearch("test") // from NY
+                .setQuery(boolQuery().must(geoPolygonQuery("location", points))),
+            response -> {
+                assertHitCount(response, 4);
+                assertThat(response.getHits().getHits().length, equalTo(4));
+                for (SearchHit hit : response.getHits()) {
+                    assertThat(hit.getId(), anyOf(equalTo("1"), equalTo("3"), equalTo("4"), equalTo("5")));
+                }
+            }
+        );
     }
 
     public void testFieldAlias() {
@@ -178,7 +184,7 @@ public class GeoPolygonIT extends ESIntegTestCase {
         assertHitCount(
             prepareSearch("test") // from NY
                 .setQuery(boolQuery().must(geoPolygonQuery("alias", points))),
-            4
+            4L
         );
     }
 }