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()); Filter facetFilter = new QueryWrapperFilter(queryFacet.query());
facetFilter = context.filterCache().cache(facetFilter); facetFilter = context.filterCache().cache(facetFilter);
long count; long count;
if (contextFacets.queryType() == SearchContextFacets.QueryExecutionType.COLLECT) { // if we already have the doc id set, then use idset since its faster
count = executeQueryCollectorCount(context, queryFacet, facetFilter); if (context.searcher().docIdSet() != null || contextFacets.queryType() == SearchContextFacets.QueryExecutionType.IDSET) {
} else if (contextFacets.queryType() == SearchContextFacets.QueryExecutionType.IDSET) {
count = executeQueryIdSetCount(context, queryFacet, facetFilter); count = executeQueryIdSetCount(context, queryFacet, facetFilter);
} else if (contextFacets.queryType() == SearchContextFacets.QueryExecutionType.COLLECT) {
count = executeQueryCollectorCount(context, queryFacet, facetFilter);
} else { } else {
throw new ElasticSearchIllegalStateException("No matching for type [" + contextFacets.queryType() + "]"); throw new ElasticSearchIllegalStateException("No matching for type [" + contextFacets.queryType() + "]");
} }