#49166 Fix spurious test failure

This commit is contained in:
jimczi 2019-11-28 11:08:15 +01:00
parent d6445fae4b
commit 35732504ba
1 changed files with 21 additions and 14 deletions

View File

@ -44,6 +44,7 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.smileBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.smileBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.yamlBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.yamlBuilder;
import static org.elasticsearch.index.query.QueryBuilders.boolQuery; import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
import static org.elasticsearch.index.query.QueryBuilders.commonTermsQuery;
import static org.elasticsearch.index.query.QueryBuilders.geoBoundingBoxQuery; import static org.elasticsearch.index.query.QueryBuilders.geoBoundingBoxQuery;
import static org.elasticsearch.index.query.QueryBuilders.geoDistanceQuery; import static org.elasticsearch.index.query.QueryBuilders.geoDistanceQuery;
import static org.elasticsearch.index.query.QueryBuilders.geoPolygonQuery; import static org.elasticsearch.index.query.QueryBuilders.geoPolygonQuery;
@ -371,25 +372,31 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
client().prepareIndex("test", "type", "1") client().prepareIndex("test", "type", "1")
.setSource(jsonBuilder().startObject() .setSource(jsonBuilder().startObject()
.field("id", "1") .field("id", 1)
.field("query", multiMatchQuery("quick brown fox", "field1", "field2") .field("query", commonTermsQuery("field1", "quick brown fox")).endObject())
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)).endObject())
.get(); .get();
client().prepareIndex("test", "type", "2") client().prepareIndex("test", "type", "2")
.setSource(jsonBuilder().startObject() .setSource(jsonBuilder().startObject()
.field("id", "2") .field("id", 2)
.field("query", multiMatchQuery("quick brown fox", "field1", "field2")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS))
.endObject())
.get();
client().prepareIndex("test", "type", "3")
.setSource(jsonBuilder().startObject()
.field("id", 3)
.field("query", .field("query",
spanNearQuery(spanTermQuery("field1", "quick"), 0) spanNearQuery(spanTermQuery("field1", "quick"), 0)
.addClause(spanTermQuery("field1", "brown")) .addClause(spanTermQuery("field1", "brown"))
.addClause(spanTermQuery("field1", "fox")) .addClause(spanTermQuery("field1", "fox"))
.inOrder(true) .inOrder(true))
).endObject()) .endObject())
.get(); .get();
client().admin().indices().prepareRefresh().get(); client().admin().indices().prepareRefresh().get();
client().prepareIndex("test", "type", "3") client().prepareIndex("test", "type", "4")
.setSource(jsonBuilder().startObject() .setSource(jsonBuilder().startObject()
.field("id", "3") .field("id", 4)
.field("query", .field("query",
spanNotQuery( spanNotQuery(
spanNearQuery(spanTermQuery("field1", "quick"), 0) spanNearQuery(spanTermQuery("field1", "quick"), 0)
@ -399,14 +406,14 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
spanNearQuery(spanTermQuery("field1", "the"), 0) spanNearQuery(spanTermQuery("field1", "the"), 0)
.addClause(spanTermQuery("field1", "lazy")) .addClause(spanTermQuery("field1", "lazy"))
.addClause(spanTermQuery("field1", "dog")) .addClause(spanTermQuery("field1", "dog"))
.inOrder(true)).dist(2) .inOrder(true)).dist(2))
).endObject()) .endObject())
.get(); .get();
// doesn't match // doesn't match
client().prepareIndex("test", "type", "4") client().prepareIndex("test", "type", "5")
.setSource(jsonBuilder().startObject() .setSource(jsonBuilder().startObject()
.field("id", "4") .field("id", 5)
.field("query", .field("query",
spanNotQuery( spanNotQuery(
spanNearQuery(spanTermQuery("field1", "quick"), 0) spanNearQuery(spanTermQuery("field1", "quick"), 0)
@ -416,8 +423,8 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
spanNearQuery(spanTermQuery("field1", "the"), 0) spanNearQuery(spanTermQuery("field1", "the"), 0)
.addClause(spanTermQuery("field1", "lazy")) .addClause(spanTermQuery("field1", "lazy"))
.addClause(spanTermQuery("field1", "dog")) .addClause(spanTermQuery("field1", "dog"))
.inOrder(true)).dist(3) .inOrder(true)).dist(3))
).endObject()) .endObject())
.get(); .get();
client().admin().indices().prepareRefresh().get(); client().admin().indices().prepareRefresh().get();