optimize match all query against a type to be wrapped with a constant score query and not filtered
This commit is contained in:
parent
002c8a6599
commit
a380e0e169
|
@ -24,6 +24,7 @@ import org.apache.lucene.search.*;
|
||||||
import org.elasticsearch.action.search.SearchType;
|
import org.elasticsearch.action.search.SearchType;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.lucene.Lucene;
|
import org.elasticsearch.common.lucene.Lucene;
|
||||||
|
import org.elasticsearch.common.lucene.search.Queries;
|
||||||
import org.elasticsearch.common.lucene.search.function.BoostScoreFunction;
|
import org.elasticsearch.common.lucene.search.function.BoostScoreFunction;
|
||||||
import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery;
|
import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery;
|
||||||
import org.elasticsearch.index.query.ParsedQuery;
|
import org.elasticsearch.index.query.ParsedQuery;
|
||||||
|
@ -81,7 +82,13 @@ public class QueryPhase implements SearchPhase {
|
||||||
}
|
}
|
||||||
Filter searchFilter = context.mapperService().searchFilter(context.types());
|
Filter searchFilter = context.mapperService().searchFilter(context.types());
|
||||||
if (searchFilter != null) {
|
if (searchFilter != null) {
|
||||||
context.parsedQuery(new ParsedQuery(new FilteredQuery(context.query(), context.filterCache().cache(searchFilter)), context.parsedQuery()));
|
if (Queries.isMatchAllQuery(context.query())) {
|
||||||
|
Query q = new DeletionAwareConstantScoreQuery(context.filterCache().cache(searchFilter));
|
||||||
|
q.setBoost(context.query().getBoost());
|
||||||
|
context.parsedQuery(new ParsedQuery(q, context.parsedQuery()));
|
||||||
|
} else {
|
||||||
|
context.parsedQuery(new ParsedQuery(new FilteredQuery(context.query(), context.filterCache().cache(searchFilter)), context.parsedQuery()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
facetPhase.preProcess(context);
|
facetPhase.preProcess(context);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue