improve match_all query to use a filter when possible

This commit is contained in:
kimchy 2010-09-17 16:38:27 +02:00
parent 3c95d6a215
commit cd7b84e808
1 changed files with 6 additions and 0 deletions

View File

@ -19,10 +19,12 @@
package org.elasticsearch.index.query.xcontent;
import org.apache.lucene.search.DeletionAwareConstantScoreQuery;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.lucene.search.Queries;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.AbstractIndexComponent;
@ -67,6 +69,10 @@ public class MatchAllQueryParser extends AbstractIndexComponent implements XCont
}
}
if (boost == 1.0f && normsField == null) {
return new DeletionAwareConstantScoreQuery(parseContext.cacheFilterIfPossible(Queries.MATCH_ALL_FILTER));
}
MatchAllDocsQuery query = new MatchAllDocsQuery(normsField);
query.setBoost(boost);
return query;