if we already have an idset, use it

This commit is contained in:
kimchy 2010-03-24 01:53:59 +02:00
parent f4c94a35d6
commit 4851ddde13
1 changed files with 4 additions and 3 deletions

View File

@ -72,10 +72,11 @@ public class FacetsPhase implements SearchPhase {
Filter facetFilter = new QueryWrapperFilter(queryFacet.query());
facetFilter = context.filterCache().cache(facetFilter);
long count;
if (contextFacets.queryType() == SearchContextFacets.QueryExecutionType.COLLECT) {
count = executeQueryCollectorCount(context, queryFacet, facetFilter);
} else if (contextFacets.queryType() == SearchContextFacets.QueryExecutionType.IDSET) {
// if we already have the doc id set, then use idset since its faster
if (context.searcher().docIdSet() != null || contextFacets.queryType() == SearchContextFacets.QueryExecutionType.IDSET) {
count = executeQueryIdSetCount(context, queryFacet, facetFilter);
} else if (contextFacets.queryType() == SearchContextFacets.QueryExecutionType.COLLECT) {
count = executeQueryCollectorCount(context, queryFacet, facetFilter);
} else {
throw new ElasticSearchIllegalStateException("No matching for type [" + contextFacets.queryType() + "]");
}