From 7984e4e89f0238e1f1495e66f1960f7e095db0be Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Wed, 23 Sep 2020 17:02:12 +0100 Subject: [PATCH] Fix test bug in SpanMultiTermQueryBuilderTests (#62833) This test checks to see if the index has been created before version 6.4, in which case index prefixes are unavailable and so it expects to see a span multi-term wrapper. However, the production code doesn't bother with checking for versions, because if the field in question is configured with index_prefixes then it knows that it must have been created post 6.4 (you can't merge in a new index_prefixes configuration). This commit alters the test to remove the random version checks, as we know we will always have a prefix field available in this scenario. Fixes #58199 --- .../query/SpanMultiTermQueryBuilderTests.java | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/index/query/SpanMultiTermQueryBuilderTests.java b/server/src/test/java/org/elasticsearch/index/query/SpanMultiTermQueryBuilderTests.java index b20abb0a555..c9fad33b1f2 100644 --- a/server/src/test/java/org/elasticsearch/index/query/SpanMultiTermQueryBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/index/query/SpanMultiTermQueryBuilderTests.java @@ -39,7 +39,6 @@ import org.apache.lucene.search.spans.SpanMultiTermQueryWrapper; import org.apache.lucene.search.spans.SpanQuery; import org.apache.lucene.search.spans.SpanTermQuery; import org.apache.lucene.store.Directory; -import org.elasticsearch.Version; import org.elasticsearch.common.Strings; import org.elasticsearch.common.compress.CompressedXContent; import org.elasticsearch.common.io.stream.StreamOutput; @@ -53,9 +52,9 @@ import java.io.IOException; import static java.util.Collections.singleton; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.either; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.instanceOf; -import static org.hamcrest.CoreMatchers.either; import static org.hamcrest.CoreMatchers.startsWith; public class SpanMultiTermQueryBuilderTests extends AbstractQueryTestCase { @@ -189,28 +188,18 @@ public class SpanMultiTermQueryBuilderTests extends AbstractQueryTestCase