org.apache.lucene.facet.search

## Class FacetsAccumulator

- java.lang.Object
- - org.apache.lucene.facet.search.FacetsAccumulator

Direct Known Subclasses:
  StandardFacetsAccumulator

    public class FacetsAccumulator
    extends Object

Driver for Accumulating facets of faceted search requests over given documents.

WARNING: This API is experimental and might change in incompatible ways in the next release.

### Field Summary

Fields
`FacetArrays` `facetArrays`
`IndexReader` `indexReader`
`FacetSearchParams` `searchParams`
`TaxonomyReader` `taxonomyReader`

### Constructor Summary

Constructors
Constructor and Description
`FacetsAccumulator(FacetSearchParams searchParams, IndexReader indexReader, TaxonomyReader taxonomyReader)` Initializes the accumulator with the given search params, index reader and taxonomy reader.
`FacetsAccumulator(FacetSearchParams searchParams, IndexReader indexReader, TaxonomyReader taxonomyReader, FacetArrays facetArrays)` Initializes the accumulator with the given parameters as well as `FacetArrays`.

### Method Summary

Methods
`List<FacetResult>` `accumulate(List<FacetsCollector.MatchingDocs> matchingDocs)` Used by `FacetsCollector` to build the list of `facet results` that match the `facet requests` that were given in the constructor.
`static FacetsAccumulator` `create(FacetSearchParams fsp, IndexReader indexReader, TaxonomyReader taxoReader)` Creates an appropriate `FacetsAccumulator`, returning `FacetsAccumulator` when all requests are `CountFacetRequest` and only one partition is in use, otherwise `StandardFacetsAccumulator`.
`protected FacetResultsHandler` `createFacetResultsHandler(FacetRequest fr)` Creates a `FacetResultsHandler` that matches the given `FacetRequest`.
`FacetsAggregator` `getAggregator()` Returns the `FacetsAggregator` to use for aggregating the categories found in the result documents.
`protected Set<CategoryListParams>` `getCategoryLists()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### taxonomyReader

    public final TaxonomyReader taxonomyReader

#### indexReader

    public final IndexReader indexReader

#### facetArrays

    public final FacetArrays facetArrays

#### searchParams

    public FacetSearchParams searchParams

### Constructor Detail

#### FacetsAccumulator

    public FacetsAccumulator(FacetSearchParams searchParams,
                     IndexReader indexReader,
                     TaxonomyReader taxonomyReader)

Initializes the accumulator with the given search params, index reader and taxonomy reader. This constructor creates the default `FacetArrays`, which do not support reuse. If you want to use `ReusingFacetArrays`, you should use the `FacetsAccumulator(FacetSearchParams, IndexReader, TaxonomyReader, FacetArrays)` constructor.

#### FacetsAccumulator

    public FacetsAccumulator(FacetSearchParams searchParams,
                     IndexReader indexReader,
                     TaxonomyReader taxonomyReader,
                     FacetArrays facetArrays)

Initializes the accumulator with the given parameters as well as `FacetArrays`. Note that the accumulator doesn't call `FacetArrays.free()`. If you require that (only makes sense if you use `ReusingFacetArrays`, you should do it after you've finished with the accumulator.

### Method Detail

#### create

    public static FacetsAccumulator create(FacetSearchParams fsp,
                           IndexReader indexReader,
                           TaxonomyReader taxoReader)

Creates an appropriate `FacetsAccumulator`, returning `FacetsAccumulator` when all requests are `CountFacetRequest` and only one partition is in use, otherwise `StandardFacetsAccumulator`.

#### getAggregator

    public FacetsAggregator getAggregator()

Returns the `FacetsAggregator` to use for aggregating the categories found in the result documents. The default implementation returns `CountingFacetsAggregator`, or `FastCountingFacetsAggregator` if all categories can be decoded with `DGapVInt8IntDecoder`.

#### createFacetResultsHandler

    protected FacetResultsHandler createFacetResultsHandler(FacetRequest fr)

Creates a `FacetResultsHandler` that matches the given `FacetRequest`.

#### getCategoryLists

    protected Set<CategoryListParams> getCategoryLists()

#### accumulate

    public List<FacetResult> accumulate(List<FacetsCollector.MatchingDocs> matchingDocs)
                                 throws IOException

Used by `FacetsCollector` to build the list of `facet results` that match the `facet requests` that were given in the constructor.

Parameters:
  `matchingDocs` - the documents that matched the query, per-segment.
Throws:
  `IOException`