reset queryGeometry in ShapeQueryTests (#45974) (#46251)

This commit is contained in:
Ignacio Vera 2019-09-03 10:24:46 +02:00 committed by GitHub
parent 416419e4c9
commit 59c474e675
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -62,6 +62,8 @@ public class ShapeQueryTests extends ESSingleNodeTestCase {
// index random shapes // index random shapes
numDocs = randomIntBetween(25, 50); numDocs = randomIntBetween(25, 50);
// reset query geometry to make sure we pick one from the indexed shapes
queryGeometry = null;
Geometry geometry; Geometry geometry;
for (int i = 0; i < numDocs; ++i) { for (int i = 0; i < numDocs; ++i) {
geometry = ShapeTestUtils.randomGeometry(false); 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(); client().prepareIndex(IGNORE_MALFORMED_INDEX, FIELD_TYPE).setRefreshPolicy(IMMEDIATE).setSource(geoJson).get();
} catch (Exception e) { } catch (Exception e) {
// sometimes GeoTestUtil will create invalid geometry; catch and continue: // sometimes GeoTestUtil will create invalid geometry; catch and continue:
if (queryGeometry == geometry) {
// reset query geometry as it didn't get indexed
queryGeometry = null;
}
--i; --i;
continue; continue;
} }
@ -227,7 +233,6 @@ public class ShapeQueryTests extends ESSingleNodeTestCase {
assertHitCount(result, numDocs); assertHitCount(result, numDocs);
} }
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/45628")
public void testFieldAlias() { public void testFieldAlias() {
SearchResponse response = client().prepareSearch(INDEX) SearchResponse response = client().prepareSearch(INDEX)
.setQuery(new ShapeQueryBuilder("alias", queryGeometry).relation(ShapeRelation.INTERSECTS)) .setQuery(new ShapeQueryBuilder("alias", queryGeometry).relation(ShapeRelation.INTERSECTS))