Is there a way by using FacetCollector to get the result with numhits as 0.
Below is the code that I am using for facet search.

FacetsCollector facetCollector = new FacetsCollector();
FacetsCollector.search(searcher, drillDownQuery, limit, facetCollector);

Here if we pass limit as 0 then we get error as "numHits must be > 0; please
use TotalHitCountCollector if you just need the total hit count"

So in order to have this fix I changed the code like 

FacetsCollector facetCollector = new FacetsCollector();
TopDocs topDocs = null;
TotalHitCountCollector totalHitCountCollector = null;
if (limit == 0) {
        totalHitCountCollector = new TotalHitCountCollector();
        topDocs = FacetsCollector.search(st.searcher, filterQuery, first + 
        MultiCollector.wrap(totalHitCountCollector, facetCollector));
} else
        topDocs = FacetsCollector.search(st.searcher, filterQuery, first + 

But there is difference in output when limit is 0 and limit is greater than

E.g. if we provide facet filter which does not fetch any record then for
limit greater than 0 which uses FacetCollector search we do not get any
facet information since result is not returned.

But for limit=0 we get facet information even though the result is not

View this message in context: 
Sent from the Lucene - Java Developer mailing list archive at Nabble.com.

To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to