org.apache.lucene.facet.search

## Class FacetsCollector

- java.lang.Object
- - org.apache.lucene.search.Collector
  - - org.apache.lucene.facet.search.FacetsCollector

-     public abstract class FacetsCollector
      extends Collector

  A `Collector` which executes faceted search and computes the weight of requested facets. To get the facet results you should call `getFacetResults()`. `create(FacetSearchParams, IndexReader, TaxonomyReader)` returns the most optimized `FacetsCollector` for the given parameters.
  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `FacetsCollector.MatchingDocs` Holds the documents that were matched in the `AtomicReaderContext`.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected List<FacetsCollector.MatchingDocs>` | `matchingDocs`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `FacetsCollector(FacetsAccumulator accumulator)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static FacetsCollector` | `create(FacetsAccumulator accumulator)` Creates a `FacetsCollector` that satisfies the requirements of the given `FacetsAccumulator`.
    `static FacetsCollector` | `create(FacetSearchParams fsp, IndexReader indexReader, TaxonomyReader taxoReader)` Creates a `FacetsCollector` using the `FacetsAccumulator` from `FacetsAccumulator.create(org.apache.lucene.facet.params.FacetSearchParams, org.apache.lucene.index.IndexReader, org.apache.lucene.facet.taxonomy.TaxonomyReader)`.
    `protected abstract void` | `finish()` Called when the Collector has finished, so that the last `FacetsCollector.MatchingDocs` can be added.
    `List<FacetResult>` | `getFacetResults()` Returns a `FacetResult` per `FacetRequest` set in `FacetSearchParams`.
    `List<FacetsCollector.MatchingDocs>` | `getMatchingDocs()` Returns the documents matched by the query, one `FacetsCollector.MatchingDocs` per visited segment.
    `void` | `reset()` Allows to reuse the collector between search requests.

    - ### Methods inherited from class org.apache.lucene.search.Collector

      `acceptsDocsOutOfOrder, collect, setNextReader, setScorer`

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

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

- - ### Field Detail

    - #### matchingDocs

          protected final List<FacetsCollector.MatchingDocs> matchingDocs

  - ### Constructor Detail

    - #### FacetsCollector

          protected FacetsCollector(FacetsAccumulator accumulator)

  - ### Method Detail

    - #### create

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

      Creates a `FacetsCollector` using the `FacetsAccumulator` from `FacetsAccumulator.create(org.apache.lucene.facet.params.FacetSearchParams, org.apache.lucene.index.IndexReader, org.apache.lucene.facet.taxonomy.TaxonomyReader)`.

    - #### create

          public static FacetsCollector create(FacetsAccumulator accumulator)

      Creates a `FacetsCollector` that satisfies the requirements of the given `FacetsAccumulator`.

    - #### finish

          protected abstract void finish()

      Called when the Collector has finished, so that the last `FacetsCollector.MatchingDocs` can be added.

    - #### getFacetResults

          public final List<FacetResult> getFacetResults()
                                                  throws IOException

      Returns a `FacetResult` per `FacetRequest` set in `FacetSearchParams`. Note that if one of the `requests` is for a `CategoryPath` that does not exist in the taxonomy, no matching `FacetResult` will be returned.
      Throws:
        `IOException`

    - #### getMatchingDocs

          public final List<FacetsCollector.MatchingDocs> getMatchingDocs()

      Returns the documents matched by the query, one `FacetsCollector.MatchingDocs` per visited segment.

    - #### reset

          public final void reset()

      Allows to reuse the collector between search requests. This method simply clears all collected documents (and scores) information, and does not attempt to reuse allocated memory spaces.

Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.