Fix ids query test when none or ALL type is used

See #24460
This commit is contained in:
Ryan Ernst 2017-05-09 14:52:28 -07:00
parent d2416a3a40
commit 53f6d9412e
1 changed files with 3 additions and 1 deletions

View File

@ -25,6 +25,7 @@ import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.Query; import org.apache.lucene.search.Query;
import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.ParsingException;
import org.elasticsearch.index.mapper.UidFieldMapper;
import org.elasticsearch.search.internal.SearchContext; import org.elasticsearch.search.internal.SearchContext;
import org.elasticsearch.test.AbstractQueryTestCase; import org.elasticsearch.test.AbstractQueryTestCase;
@ -73,7 +74,8 @@ public class IdsQueryBuilderTests extends AbstractQueryTestCase<IdsQueryBuilder>
@Override @Override
protected void doAssertLuceneQuery(IdsQueryBuilder queryBuilder, Query query, SearchContext context) throws IOException { protected void doAssertLuceneQuery(IdsQueryBuilder queryBuilder, Query query, SearchContext context) throws IOException {
if (queryBuilder.ids().size() == 0) { if (queryBuilder.ids().size() == 0 || queryBuilder.types().length == 0 ||
(queryBuilder.types().length == 1 && queryBuilder.types()[0].equals(MetaData.ALL))) {
assertThat(query, instanceOf(MatchNoDocsQuery.class)); assertThat(query, instanceOf(MatchNoDocsQuery.class));
} else { } else {
assertThat(query, instanceOf(TermInSetQuery.class)); assertThat(query, instanceOf(TermInSetQuery.class));