improve match_all query to use a filter when possible
This commit is contained in:
parent
3c95d6a215
commit
cd7b84e808
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue