/** search reader <code>r</code>*/
private FacetResult searchWithFacets(IndexReader r, TaxonomyReader tr,
FacetSearchParams fsp, final SamplingParams params) throws IOException {
// a FacetsCollector with a sampling accumulator
FacetsCollector fcWithSampling = new FacetsCollector(fsp, r, tr) {
@Override
protected FacetsAccumulator initFacetsAccumulator(FacetSearchParams facetSearchParams, IndexReader indexReader,
TaxonomyReader taxonomyReader) {
Sampler sampler = new RandomSampler(params, random);
return new SamplingAccumulator(sampler, facetSearchParams, indexReader, taxonomyReader);
}
};
IndexSearcher s = new IndexSearcher(r);
s.search(new MatchAllDocsQuery(), fcWithSampling);
s.close();
// there's only one expected result, return just it.
return fcWithSampling.getFacetResults().get(0);
}