lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maahi333 <maahi...@gmail.com>
Subject Drill down facet using numhits as zero.
Date Wed, 12 Oct 2016 10:13:40 GMT
HI,

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 + limit,
	MultiCollector.wrap(totalHitCountCollector, facetCollector));
} else
	topDocs = FacetsCollector.search(st.searcher, filterQuery, first + limit,
facetCollector);

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

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
present.








--
View this message in context: http://lucene.472066.n3.nabble.com/Drill-down-facet-using-numhits-as-zero-tp4300838.html
Sent from the Lucene - Java Developer mailing list archive at Nabble.com.

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


Mime
View raw message