From 59c474e67523ea3f538a217bb1300b3af5e45600 Mon Sep 17 00:00:00 2001 From: Ignacio Vera Date: Tue, 3 Sep 2019 10:24:46 +0200 Subject: [PATCH] reset queryGeometry in ShapeQueryTests (#45974) (#46251) --- .../xpack/spatial/search/ShapeQueryTests.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/search/ShapeQueryTests.java b/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/search/ShapeQueryTests.java index 7a9476aa522..937790b56ab 100644 --- a/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/search/ShapeQueryTests.java +++ b/x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/search/ShapeQueryTests.java @@ -62,6 +62,8 @@ public class ShapeQueryTests extends ESSingleNodeTestCase { // index random shapes numDocs = randomIntBetween(25, 50); + // reset query geometry to make sure we pick one from the indexed shapes + queryGeometry = null; Geometry geometry; for (int i = 0; i < numDocs; ++i) { geometry = ShapeTestUtils.randomGeometry(false); @@ -77,6 +79,10 @@ public class ShapeQueryTests extends ESSingleNodeTestCase { client().prepareIndex(IGNORE_MALFORMED_INDEX, FIELD_TYPE).setRefreshPolicy(IMMEDIATE).setSource(geoJson).get(); } catch (Exception e) { // sometimes GeoTestUtil will create invalid geometry; catch and continue: + if (queryGeometry == geometry) { + // reset query geometry as it didn't get indexed + queryGeometry = null; + } --i; continue; } @@ -227,7 +233,6 @@ public class ShapeQueryTests extends ESSingleNodeTestCase { assertHitCount(result, numDocs); } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/45628") public void testFieldAlias() { SearchResponse response = client().prepareSearch(INDEX) .setQuery(new ShapeQueryBuilder("alias", queryGeometry).relation(ShapeRelation.INTERSECTS))