Package org.apache.lucene.search

## Class TopScoreDocCollectorManager

- java.lang.Object
- - org.apache.lucene.search.TopScoreDocCollectorManager

- All Implemented Interfaces:
    `CollectorManager<TopScoreDocCollector,​TopDocs>`

      public class TopScoreDocCollectorManager
      extends Object
      implements CollectorManager<TopScoreDocCollector,​TopDocs>

  Create a TopScoreDocCollectorManager which uses a shared hit counter to maintain number of hits and a shared `MaxScoreAccumulator` to propagate the minimum score across segments

  Note that a new collectorManager should be created for each search due to its internal states.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `TopScoreDocCollectorManager​(int numHits, int totalHitsThreshold)` | Creates a new `TopScoreDocCollectorManager` given the number of hits to collect and the number of hits to count accurately, with thread-safe internal states.
    `TopScoreDocCollectorManager​(int numHits, ScoreDoc after, int totalHitsThreshold)` | Creates a new `TopScoreDocCollectorManager` given the number of hits to collect and the number of hits to count accurately, with thread-safe internal states.
    `TopScoreDocCollectorManager​(int numHits, ScoreDoc after, int totalHitsThreshold, boolean supportsConcurrency)` | Creates a new `TopScoreDocCollectorManager` given the number of hits to collect and the number of hits to count accurately.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `TopScoreDocCollector` | `newCollector()` | Return a new `Collector`.
    `TopDocs` | `reduce​(Collection<TopScoreDocCollector> collectors)` | Reduce the results of individual collectors into a meaningful result.

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

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

- - ### Constructor Detail

    - #### TopScoreDocCollectorManager

          public TopScoreDocCollectorManager​(int numHits,
                                             ScoreDoc after,
                                             int totalHitsThreshold,
                                             boolean supportsConcurrency)

      Creates a new `TopScoreDocCollectorManager` given the number of hits to collect and the number of hits to count accurately.

      NOTE: If the total hit count of the top docs is less than or exactly `totalHitsThreshold` then this value is accurate. On the other hand, if the `TopDocs.totalHits` value is greater than `totalHitsThreshold` then its value is a lower bound of the hit count. A value of `Integer.MAX_VALUE` will make the hit count accurate but will also likely make query processing slower.

      NOTE: The instances returned by this method pre-allocate a full array of length `numHits`, and fill the array with sentinel objects.

      Parameters:
        `numHits` - the number of results to collect.
        `after` - the previous doc after which matching docs will be collected.
        `totalHitsThreshold` - the number of docs to count accurately. If the query matches more than `totalHitsThreshold` hits then its hit count will be a lower bound. On the other hand if the query matches less than or exactly `totalHitsThreshold` hits then the hit count of the result will be accurate. `Integer.MAX_VALUE` may be used to make the hit count accurate, but this will also make query processing slower.
        `supportsConcurrency` - to use thread-safe and slower internal states for count tracking.

    - #### TopScoreDocCollectorManager

          public TopScoreDocCollectorManager​(int numHits,
                                             ScoreDoc after,
                                             int totalHitsThreshold)

      Creates a new `TopScoreDocCollectorManager` given the number of hits to collect and the number of hits to count accurately, with thread-safe internal states.

      NOTE: If the total hit count of the top docs is less than or exactly `totalHitsThreshold` then this value is accurate. On the other hand, if the `TopDocs.totalHits` value is greater than `totalHitsThreshold` then its value is a lower bound of the hit count. A value of `Integer.MAX_VALUE` will make the hit count accurate but will also likely make query processing slower.

      NOTE: The instances returned by this method pre-allocate a full array of length `numHits`, and fill the array with sentinel objects.

      Parameters:
        `numHits` - the number of results to collect.
        `after` - the previous doc after which matching docs will be collected.
        `totalHitsThreshold` - the number of docs to count accurately. If the query matches more than `totalHitsThreshold` hits then its hit count will be a lower bound. On the other hand if the query matches less than or exactly `totalHitsThreshold` hits then the hit count of the result will be accurate. `Integer.MAX_VALUE` may be used to make the hit count accurate, but this will also make query processing slower.

    - #### TopScoreDocCollectorManager

          public TopScoreDocCollectorManager​(int numHits,
                                             int totalHitsThreshold)

      Creates a new `TopScoreDocCollectorManager` given the number of hits to collect and the number of hits to count accurately, with thread-safe internal states.

      NOTE: If the total hit count of the top docs is less than or exactly `totalHitsThreshold` then this value is accurate. On the other hand, if the `TopDocs.totalHits` value is greater than `totalHitsThreshold` then its value is a lower bound of the hit count. A value of `Integer.MAX_VALUE` will make the hit count accurate but will also likely make query processing slower.

      NOTE: The instances returned by this method pre-allocate a full array of length `numHits`, and fill the array with sentinel objects.

      Parameters:
        `numHits` - the number of results to collect.
        `totalHitsThreshold` - the number of docs to count accurately. If the query matches more than `totalHitsThreshold` hits then its hit count will be a lower bound. On the other hand if the query matches less than or exactly `totalHitsThreshold` hits then the hit count of the result will be accurate. `Integer.MAX_VALUE` may be used to make the hit count accurate, but this will also make query processing slower.

  - ### Method Detail

    - #### newCollector

          public TopScoreDocCollector newCollector()

      Description copied from interface: `CollectorManager`
      Return a new `Collector`. This must return a different instance on each call.
      Specified by:
        `newCollector` in interface `CollectorManager<TopScoreDocCollector,​TopDocs>`

    - #### reduce

          public TopDocs reduce​(Collection<TopScoreDocCollector> collectors)
                         throws IOException

      Description copied from interface: `CollectorManager`
      Reduce the results of individual collectors into a meaningful result. For instance a `TopDocsCollector` would compute the `top docs` of each collector and then merge them using `TopDocs.merge(int, TopDocs[])`. This method must be called after collection is finished on all provided collectors.
      Specified by:
        `reduce` in interface `CollectorManager<TopScoreDocCollector,​TopDocs>`
      Throws:
        `IOException`