org.apache.lucene.search

## Class LargeNumHitsTopDocsCollector

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

- All Implemented Interfaces:
    Collector

      public final class LargeNumHitsTopDocsCollector
      extends Object
      implements Collector

  Optimized collector for large number of hits. The collector maintains an ArrayList of hits until it accumulates the requested number of hits. Post that, it builds a Priority Queue and starts filtering further hits based on the minimum competitive score.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `LargeNumHitsTopDocsCollector(int requestedHitCount)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `LeafCollector` | `getLeafCollector(LeafReaderContext context)`
    `protected TopDocs` | `newTopDocs(ScoreDoc[] results)` Returns a `TopDocs` instance containing the given results.
    `protected void` | `populateResults(ScoreDoc[] results, int howMany)` Populates the results array with the ScoreDoc instances.
    `ScoreMode` | `scoreMode()`
    `TopDocs` | `topDocs()` Returns the top docs that were collected by this collector.
    `TopDocs` | `topDocs(int howMany)` Returns the top docs that were collected by this collector.

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

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

- - ### Constructor Detail

    - #### LargeNumHitsTopDocsCollector

          public LargeNumHitsTopDocsCollector(int requestedHitCount)

  - ### Method Detail

    - #### scoreMode

          public ScoreMode scoreMode()

      Specified by:
        `scoreMode` in interface `Collector`

    - #### getLeafCollector

          public LeafCollector getLeafCollector(LeafReaderContext context)

      Specified by:
        `getLeafCollector` in interface `Collector`

    - #### topDocs

          public TopDocs topDocs(int howMany)

      Returns the top docs that were collected by this collector.

    - #### populateResults

          protected void populateResults(ScoreDoc[] results,
                                         int howMany)

      Populates the results array with the ScoreDoc instances. This can be overridden in case a different ScoreDoc type should be returned.

    - #### newTopDocs

          protected TopDocs newTopDocs(ScoreDoc[] results)

      Returns a `TopDocs` instance containing the given results. If `results` is null it means there are no results to return, either because there were 0 calls to collect() or because the arguments to topDocs were invalid.

    - #### topDocs

          public TopDocs topDocs()

      Returns the top docs that were collected by this collector.

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