Skip to content

Commit 54d896c

Browse files
author
Christoph Büscher
authored
[Tests] Remove QueryStringQueryBuilderTests#toQuery class assertions (#32236)
Currently we check that the queries that QueryStringQueryBuilder#toQuery returns is one out of a list of many Lucene query classes. This list has extended a lot over time, since QueryStringQueryBuilder can build all sort of queries. This makes the test hard to maintain. The recent addition of alias fields which build a BlendedTermQuery show how easy this test breaks. Also the current assertions doesn't add a lot in terms of catching errors. This is why we decided to remove this check. Closes #32234
1 parent af0c1d3 commit 54d896c

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

server/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import org.apache.lucene.search.WildcardQuery;
4343
import org.apache.lucene.search.spans.SpanNearQuery;
4444
import org.apache.lucene.search.spans.SpanOrQuery;
45-
import org.apache.lucene.search.spans.SpanQuery;
4645
import org.apache.lucene.search.spans.SpanTermQuery;
4746
import org.apache.lucene.util.BytesRef;
4847
import org.apache.lucene.util.automaton.TooComplexToDeterminizeException;
@@ -51,7 +50,6 @@
5150
import org.elasticsearch.cluster.metadata.IndexMetaData;
5251
import org.elasticsearch.common.Strings;
5352
import org.elasticsearch.common.compress.CompressedXContent;
54-
import org.elasticsearch.common.lucene.search.MultiPhrasePrefixQuery;
5553
import org.elasticsearch.common.settings.Settings;
5654
import org.elasticsearch.common.unit.Fuzziness;
5755
import org.elasticsearch.common.xcontent.XContentBuilder;
@@ -74,7 +72,6 @@
7472
import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery;
7573
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBooleanSubQuery;
7674
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertDisjunctionSubQuery;
77-
import static org.hamcrest.CoreMatchers.either;
7875
import static org.hamcrest.CoreMatchers.equalTo;
7976
import static org.hamcrest.Matchers.containsString;
8077
import static org.hamcrest.Matchers.instanceOf;
@@ -381,11 +378,7 @@ public QueryStringQueryBuilder mutateInstance(QueryStringQueryBuilder instance)
381378
@Override
382379
protected void doAssertLuceneQuery(QueryStringQueryBuilder queryBuilder,
383380
Query query, SearchContext context) throws IOException {
384-
assertThat(query, either(instanceOf(TermQuery.class))
385-
.or(instanceOf(BooleanQuery.class)).or(instanceOf(DisjunctionMaxQuery.class))
386-
.or(instanceOf(PhraseQuery.class)).or(instanceOf(BoostQuery.class))
387-
.or(instanceOf(MultiPhrasePrefixQuery.class)).or(instanceOf(PrefixQuery.class)).or(instanceOf(SpanQuery.class))
388-
.or(instanceOf(MatchNoDocsQuery.class)));
381+
// nothing yet, put additional assertions here.
389382
}
390383

391384
// Tests fix for https://github.com/elastic/elasticsearch/issues/29403

0 commit comments

Comments
 (0)