Class TopFieldCollector

    • Method Detail

      • needsScores

        public boolean needsScores()
        Description copied from interface: Collector
        Indicates if document scores are needed by this collector.
        Returns:
        true if scores are needed.
      • create

        @Deprecated
        public static TopFieldCollector create​(Sort sort,
                                               int numHits,
                                               boolean fillFields,
                                               boolean trackDocScores,
                                               boolean trackMaxScore)
        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.
        fillFields - specifies whether the actual field values should be returned on the results (FieldDoc).
        trackDocScores - specifies whether document scores should be tracked and set on the results. Note that if set to false, then the results' scores will be set to Float.NaN. Setting this to true affects performance, as it incurs the score computation on each competitive result. Therefore if document scores are not required by the application, it is recommended to set it to false.
        trackMaxScore - specifies whether the query's maxScore should be tracked and set on the resulting TopDocs. Note that if set to false, TopDocs.getMaxScore() returns Float.NaN. Setting this to true affects performance as it incurs the score computation on each result. Also, setting this true automatically sets trackDocScores to true as well.
        Returns:
        a TopFieldCollector instance which will sort the results by the sort criteria.
      • create

        public static TopFieldCollector create​(Sort sort,
                                               int numHits,
                                               boolean fillFields,
                                               boolean trackDocScores,
                                               boolean trackMaxScore,
                                               boolean trackTotalHits)
        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.
        fillFields - specifies whether the actual field values should be returned on the results (FieldDoc).
        trackDocScores - specifies whether document scores should be tracked and set on the results. Note that if set to false, then the results' scores will be set to Float.NaN. Setting this to true affects performance, as it incurs the score computation on each competitive result. Therefore if document scores are not required by the application, it is recommended to set it to false.
        trackMaxScore - specifies whether the query's maxScore should be tracked and set on the resulting TopDocs. Note that if set to false, TopDocs.getMaxScore() returns Float.NaN. Setting this to true affects performance as it incurs the score computation on each result. Also, setting this true automatically sets trackDocScores to true as well.
        trackTotalHits - specifies whether the total number of hits should be tracked. If set to false, the value of TopDocs.totalHits will be approximated.
        Returns:
        a TopFieldCollector instance which will sort the results by the sort criteria.
      • create

        @Deprecated
        public static TopFieldCollector create​(Sort sort,
                                               int numHits,
                                               FieldDoc after,
                                               boolean fillFields,
                                               boolean trackDocScores,
                                               boolean trackMaxScore)
        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
        fillFields - specifies whether the actual field values should be returned on the results (FieldDoc).
        trackDocScores - specifies whether document scores should be tracked and set on the results. Note that if set to false, then the results' scores will be set to Float.NaN. Setting this to true affects performance, as it incurs the score computation on each competitive result. Therefore if document scores are not required by the application, it is recommended to set it to false.
        trackMaxScore - specifies whether the query's maxScore should be tracked and set on the resulting TopDocs. Note that if set to false, TopDocs.getMaxScore() returns Float.NaN. Setting this to true affects performance as it incurs the score computation on each result. Also, setting this true automatically sets trackDocScores to true as well.
        Returns:
        a TopFieldCollector instance which will sort the results by the sort criteria.
      • create

        public static TopFieldCollector create​(Sort sort,
                                               int numHits,
                                               FieldDoc after,
                                               boolean fillFields,
                                               boolean trackDocScores,
                                               boolean trackMaxScore,
                                               boolean trackTotalHits)
        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
        fillFields - specifies whether the actual field values should be returned on the results (FieldDoc).
        trackDocScores - specifies whether document scores should be tracked and set on the results. Note that if set to false, then the results' scores will be set to Float.NaN. Setting this to true affects performance, as it incurs the score computation on each competitive result. Therefore if document scores are not required by the application, it is recommended to set it to false.
        trackMaxScore - specifies whether the query's maxScore should be tracked and set on the resulting TopDocs. Note that if set to false, TopDocs.getMaxScore() returns Float.NaN. Setting this to true affects performance as it incurs the score computation on each result. Also, setting this true automatically sets trackDocScores to true as well.
        trackTotalHits - specifies whether the total number of hits should be tracked. If set to false, the value of TopDocs.totalHits will be approximated.
        Returns:
        a TopFieldCollector instance which will sort the results by the sort criteria.
      • isEarlyTerminated

        public boolean isEarlyTerminated()
        Return whether collection terminated early.