Class RandomSamplingFacetsCollector

All Implemented Interfaces:
Collector, LeafCollector

public class RandomSamplingFacetsCollector extends FacetsCollector
Collects hits for subsequent faceting, using sampling if needed. Once you've run a search and collect hits into this, instantiate one of the Facets subclasses to do the facet counting. Note that this collector does not collect the scores of matching docs (i.e. FacetsCollector.MatchingDocs.scores) is null.

If you require the original set of hits, you can call getOriginalMatchingDocs(). Also, since the counts of the top-facets is based on the sampled set, you can amortize the counts by calling amortizeFacetCounts(org.apache.lucene.facet.FacetResult, org.apache.lucene.facet.FacetsConfig, org.apache.lucene.search.IndexSearcher).

  • Constructor Details

    • RandomSamplingFacetsCollector

      public RandomSamplingFacetsCollector(int sampleSize)
      Constructor with the given sample size and default seed.
      See Also:
    • RandomSamplingFacetsCollector

      public RandomSamplingFacetsCollector(int sampleSize, long seed)
      Constructor with the given sample size and seed.
      Parameters:
      sampleSize - The preferred sample size. If the number of hits is greater than the size, sampling will be done using a sample ratio of sampling size / totalN. For example: 1000 hits, sample size = 10 results in samplingRatio of 0.01. If the number of hits is lower, no sampling is done at all
      seed - The random seed. If 0 then a seed will be chosen for you.
  • Method Details