[TEST] adapt FilteredQueryBuilderTests to upstream changes
This commit is contained in:
parent
8bd7cdbdad
commit
ea83007c7e
|
@ -21,9 +21,7 @@ package org.elasticsearch.index.query;
|
||||||
|
|
||||||
import org.apache.lucene.search.BooleanClause;
|
import org.apache.lucene.search.BooleanClause;
|
||||||
import org.apache.lucene.search.BooleanQuery;
|
import org.apache.lucene.search.BooleanQuery;
|
||||||
import org.apache.lucene.search.ConstantScoreQuery;
|
|
||||||
import org.apache.lucene.search.Query;
|
import org.apache.lucene.search.Query;
|
||||||
import org.elasticsearch.common.lucene.search.Queries;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -47,18 +45,15 @@ public class FilteredQueryBuilderTests extends BaseQueryTestCase<FilteredQueryBu
|
||||||
Query innerQuery = queryBuilder.innerQuery().toQuery(context);
|
Query innerQuery = queryBuilder.innerQuery().toQuery(context);
|
||||||
if (innerQuery == null) {
|
if (innerQuery == null) {
|
||||||
assertThat(query, nullValue());
|
assertThat(query, nullValue());
|
||||||
} else {
|
|
||||||
Query innerFilter = queryBuilder.innerFilter().toQuery(context);
|
|
||||||
if (innerFilter == null || Queries.isConstantMatchAllQuery(innerFilter)) {
|
|
||||||
innerQuery.setBoost(queryBuilder.boost());
|
|
||||||
assertThat(query, equalTo(innerQuery));
|
|
||||||
} else if (Queries.isConstantMatchAllQuery(innerQuery)) {
|
|
||||||
assertThat(query, instanceOf(ConstantScoreQuery.class));
|
|
||||||
assertThat(((ConstantScoreQuery)query).getQuery(), equalTo(innerFilter));
|
|
||||||
} else {
|
} else {
|
||||||
assertThat(query, instanceOf(BooleanQuery.class));
|
assertThat(query, instanceOf(BooleanQuery.class));
|
||||||
BooleanQuery booleanQuery = (BooleanQuery) query;
|
BooleanQuery booleanQuery = (BooleanQuery) query;
|
||||||
assertThat(booleanQuery.clauses().size(), equalTo(2));
|
Query innerFilter = queryBuilder.innerFilter().toQuery(context);
|
||||||
|
if (innerFilter == null) {
|
||||||
|
assertThat(booleanQuery.clauses().size(), equalTo(1));
|
||||||
|
assertThat(booleanQuery.clauses().get(0).getOccur(), equalTo(BooleanClause.Occur.MUST));
|
||||||
|
assertThat(booleanQuery.clauses().get(0).getQuery(), equalTo(innerQuery));
|
||||||
|
} else {
|
||||||
assertThat(booleanQuery.clauses().get(0).getOccur(), equalTo(BooleanClause.Occur.MUST));
|
assertThat(booleanQuery.clauses().get(0).getOccur(), equalTo(BooleanClause.Occur.MUST));
|
||||||
assertThat(booleanQuery.clauses().get(0).getQuery(), equalTo(innerQuery));
|
assertThat(booleanQuery.clauses().get(0).getQuery(), equalTo(innerQuery));
|
||||||
assertThat(booleanQuery.clauses().get(1).getOccur(), equalTo(BooleanClause.Occur.FILTER));
|
assertThat(booleanQuery.clauses().get(1).getOccur(), equalTo(BooleanClause.Occur.FILTER));
|
||||||
|
|
Loading…
Reference in New Issue