Skip to content

Commit

Permalink
[Tests] Fix SimpleQueryStringBuilderTests
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Büscher committed Nov 21, 2018
1 parent 51dd49f commit defe10f
Showing 1 changed file with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,7 @@ public void testDefaultFieldParsing() throws IOException {
@Override
protected void doAssertLuceneQuery(SimpleQueryStringBuilder queryBuilder, Query query, SearchContext context) throws IOException {
assertThat(query, notNullValue());

if (queryBuilder.value().isEmpty()) {
if (queryBuilder.value().isEmpty() || getCurrentTypes().length == 0) {
assertThat(query, instanceOf(MatchNoDocsQuery.class));
} else if (queryBuilder.fields().size() > 1) {
assertThat(query, instanceOf(DisjunctionMaxQuery.class));
Expand Down Expand Up @@ -707,20 +706,14 @@ public void testWithPrefixStopWords() throws Exception {
assertEquals(expected, query);
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/35773")
@Override
public void testToQuery() throws IOException {
super.testToQuery();
}

/**
* Test for behavior reported in https://github.com/elastic/elasticsearch/issues/34708
* Unmapped field can lead to MatchNoDocsQuerys in disjunction queries. If tokens are eliminated (e.g. because
* the tokenizer removed them as punctuation) on regular fields, this can leave only MatchNoDocsQuerys in the
* disjunction clause. Instead those disjunctions should be eliminated completely.
*/
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/35773")
public void testUnmappedFieldNoTokenWithAndOperator() throws IOException {
assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
Query query = new SimpleQueryStringBuilder("first & second")
.field(STRING_FIELD_NAME)
.field("unmapped")
Expand Down

0 comments on commit defe10f

Please sign in to comment.