Fix TermsQueryBuilderTests expectations.

This commit is contained in:
Adrien Grand 2016-11-30 17:07:53 +01:00
parent 34e682d3bc
commit f5ac27a20d
1 changed files with 8 additions and 1 deletions

View File

@ -20,6 +20,8 @@
package org.elasticsearch.index.query;
import org.apache.lucene.queries.TermsQuery;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.ConstantScoreQuery;
import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.PointInSetQuery;
import org.apache.lucene.search.Query;
@ -108,7 +110,12 @@ public class TermsQueryBuilderTests extends AbstractQueryTestCase<TermsQueryBuil
MatchNoDocsQuery matchNoDocsQuery = (MatchNoDocsQuery) query;
assertThat(matchNoDocsQuery.toString(), containsString("No terms supplied for \"terms\" query."));
} else {
assertThat(query, either(instanceOf(TermsQuery.class)).or(instanceOf(PointInSetQuery.class)));
assertThat(query, either(instanceOf(TermsQuery.class))
.or(instanceOf(PointInSetQuery.class))
.or(instanceOf(ConstantScoreQuery.class)));
if (query instanceof ConstantScoreQuery) {
assertThat(((ConstantScoreQuery) query).getQuery(), instanceOf(BooleanQuery.class));
}
// we only do the check below for string fields (otherwise we'd have to decode the values)
if (queryBuilder.fieldName().equals(INT_FIELD_NAME) || queryBuilder.fieldName().equals(DOUBLE_FIELD_NAME)