Norms field is ignored when doing a match_all query

we shouldn't optimize a match all query if it has norms associated with it, fixes #2277
This commit is contained in:
Shay Banon 2012-09-21 18:57:21 +02:00
parent 4f5e62e988
commit a3af3d2f47
4 changed files with 4 additions and 7 deletions

View File

@ -109,13 +109,10 @@ public class Queries {
return q;
}
public static boolean isMatchAllQuery(Query query) {
public static boolean isConstantMatchAllQuery(Query query) {
if (query == Queries.MATCH_ALL_QUERY) {
return true;
}
if (query instanceof MatchAllDocsQuery) {
return true;
}
if (query instanceof DeletionAwareConstantScoreQuery) {
DeletionAwareConstantScoreQuery scoreQuery = (DeletionAwareConstantScoreQuery) query;
if (scoreQuery.getFilter() instanceof MatchAllDocsFilter) {

View File

@ -108,7 +108,7 @@ public class FilteredQueryParser implements QueryParser {
}
// if its a match_all query, use constant_score
if (Queries.isMatchAllQuery(query)) {
if (Queries.isConstantMatchAllQuery(query)) {
Query q = new DeletionAwareConstantScoreQuery(filter);
q.setBoost(boost);
return q;

View File

@ -94,7 +94,7 @@ public class QueryFacetCollector extends AbstractFacetCollector implements Optim
private Filter extractFilterIfApplicable(Query query) {
if (query instanceof FilteredQuery) {
FilteredQuery fQuery = (FilteredQuery) query;
if (Queries.isMatchAllQuery(fQuery.getQuery())) {
if (Queries.isConstantMatchAllQuery(fQuery.getQuery())) {
return fQuery.getFilter();
}
} else if (query instanceof DeletionAwareConstantScoreQuery) {

View File

@ -221,7 +221,7 @@ public class SearchContext implements Releasable {
}
Filter searchFilter = mapperService().searchFilter(types());
if (searchFilter != null) {
if (Queries.isMatchAllQuery(query())) {
if (Queries.isConstantMatchAllQuery(query())) {
Query q = new DeletionAwareConstantScoreQuery(filterCache().cache(searchFilter));
q.setBoost(query().getBoost());
parsedQuery(new ParsedQuery(q, parsedQuery()));