Class TopFieldCollector

    • Field Detail

      • EMPTY_SCOREDOCS

        private static final ScoreDoc[] EMPTY_SCOREDOCS
      • numHits

        final int numHits
      • canSetMinScore

        final boolean canSetMinScore
      • searchSortPartOfIndexSort

        java.lang.Boolean searchSortPartOfIndexSort
      • minCompetitiveScore

        float minCompetitiveScore
      • numComparators

        final int numComparators
      • queueFull

        boolean queueFull
      • docBase

        int docBase
      • needsScores

        final boolean needsScores
    • Method Detail

      • canEarlyTerminate

        static boolean canEarlyTerminate​(Sort searchSort,
                                         Sort indexSort)
      • canEarlyTerminateOnDocId

        private static boolean canEarlyTerminateOnDocId​(Sort searchSort)
      • canEarlyTerminateOnPrefix

        private static boolean canEarlyTerminateOnPrefix​(Sort searchSort,
                                                         Sort indexSort)
      • scoreMode

        public ScoreMode scoreMode()
        Description copied from interface: Collector
        Indicates what features are required from the scorer.
      • updateGlobalMinCompetitiveScore

        protected void updateGlobalMinCompetitiveScore​(Scorable scorer)
                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • updateMinCompetitiveScore

        protected void updateMinCompetitiveScore​(Scorable scorer)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • create

        public static TopFieldCollector create​(Sort sort,
                                               int numHits,
                                               int totalHitsThreshold)
        Creates a new TopFieldCollector from the given arguments.

        NOTE: The instances returned by this method pre-allocate a full array of length numHits.

        Parameters:
        sort - the sort criteria (SortFields).
        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.
        Returns:
        a TopFieldCollector instance which will sort the results by the sort criteria.
      • create

        public static TopFieldCollector create​(Sort sort,
                                               int numHits,
                                               FieldDoc after,
                                               int totalHitsThreshold)
        Creates a new TopFieldCollector from the given arguments.

        NOTE: The instances returned by this method pre-allocate a full array of length numHits.

        Parameters:
        sort - the sort criteria (SortFields).
        numHits - the number of results to collect.
        after - only hits after this FieldDoc 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. Setting totalHitsThreshold less than Integer.MAX_VALUE instructs Lucene to skip non-competitive documents whenever possible. For numeric sort fields the skipping functionality works when the same field is indexed both with doc values and points. In this case, there is an assumption that the same data is stored in these points and doc values.
        Returns:
        a TopFieldCollector instance which will sort the results by the sort criteria.
      • createSharedManager

        public static CollectorManager<TopFieldCollector,​TopFieldDocs> createSharedManager​(Sort sort,
                                                                                                 int numHits,
                                                                                                 FieldDoc after,
                                                                                                 int totalHitsThreshold)
        Create a CollectorManager which uses a shared hit counter to maintain number of hits and a shared MaxScoreAccumulator to propagate the minimum score accross segments if the primary sort is by relevancy.
      • populateScores

        public static void populateScores​(ScoreDoc[] topDocs,
                                          IndexSearcher searcher,
                                          Query query)
                                   throws java.io.IOException
        Populate scores of the given topDocs.
        Parameters:
        topDocs - the top docs to populate
        searcher - the index searcher that has been used to compute topDocs
        query - the query that has been used to compute topDocs
        Throws:
        java.lang.IllegalArgumentException - if there is evidence that topDocs have been computed against a different searcher or a different query.
        java.io.IOException
      • add

        final void add​(int slot,
                       int doc)
      • updateBottom

        final void updateBottom​(int doc)
      • isEarlyTerminated

        public boolean isEarlyTerminated()
        Return whether collection terminated early.