Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class TopFieldCollector

    A ICollector that sorts by SortField using FieldComparers.

    See the Create(Sort, int, bool, bool, bool, bool) method for instantiating a TopFieldCollector.

    Note

    This API is experimental and might change in incompatible ways in the next release.

    Inheritance
    object
    TopDocsCollector<FieldValueHitQueue.Entry>
    TopFieldCollector
    Implements
    ITopDocsCollector
    ICollector
    Inherited Members
    TopDocsCollector<FieldValueHitQueue.Entry>.EMPTY_TOPDOCS
    TopDocsCollector<FieldValueHitQueue.Entry>.m_pq
    TopDocsCollector<FieldValueHitQueue.Entry>.m_totalHits
    TopDocsCollector<FieldValueHitQueue.Entry>.TotalHits
    TopDocsCollector<FieldValueHitQueue.Entry>.TopDocsCount
    TopDocsCollector<FieldValueHitQueue.Entry>.GetTopDocs()
    TopDocsCollector<FieldValueHitQueue.Entry>.GetTopDocs(int)
    TopDocsCollector<FieldValueHitQueue.Entry>.GetTopDocs(int, int)
    TopDocsCollector<FieldValueHitQueue.Entry>.SetScorer(Scorer)
    TopDocsCollector<FieldValueHitQueue.Entry>.Collect(int)
    TopDocsCollector<FieldValueHitQueue.Entry>.SetNextReader(AtomicReaderContext)
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Lucene.Net.Search
    Assembly: Lucene.Net.dll
    Syntax
    public abstract class TopFieldCollector : TopDocsCollector<FieldValueHitQueue.Entry>, ITopDocsCollector, ICollector

    Properties

    AcceptsDocsOutOfOrder

    Return true if this collector does not require the matching docIDs to be delivered in int sort order (smallest to largest) to Collect(int).

    Most Lucene Query implementations will visit matching docIDs in order. However, some queries (currently limited to certain cases of BooleanQuery) can achieve faster searching if the ICollector allows them to deliver the docIDs out of order.

    Many collectors don't mind getting docIDs out of order, so it's important to return true here.

    Declaration
    public override bool AcceptsDocsOutOfOrder { get; }
    Property Value
    Type Description
    bool
    Overrides
    TopDocsCollector<FieldValueHitQueue.Entry>.AcceptsDocsOutOfOrder

    Methods

    Create(Sort, int, FieldDoc?, bool, bool, bool, bool)

    Creates a new TopFieldCollector from the given arguments.

    NOTE: The instances returned by this method pre-allocate a full array of length numHits.
    Declaration
    public static TopFieldCollector Create(Sort sort, int numHits, FieldDoc? after, bool fillFields, bool trackDocScores, bool trackMaxScore, bool docsScoredInOrder)
    Parameters
    Type Name Description
    Sort sort

    The sort criteria (SortFields).

    int numHits

    The number of results to collect.

    FieldDoc after

    Only hits after this FieldDoc will be collected

    bool fillFields

    Specifies whether the actual field values should be returned on the results (FieldDoc).

    bool 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 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.

    bool trackMaxScore

    Specifies whether the query's maxScore should be tracked and set on the resulting TopDocs. Note that if set to false, MaxScore returns 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.

    bool docsScoredInOrder

    Specifies whether documents are scored in doc Id order or not by the given Scorer in SetScorer(Scorer).

    Returns
    Type Description
    TopFieldCollector

    A TopFieldCollector instance which will sort the results by the sort criteria.

    Exceptions
    Type Condition
    IOException

    If there is a low-level I/O error

    ArgumentNullException

    sort is null.

    Create(Sort, int, bool, bool, bool, bool)

    Creates a new TopFieldCollector from the given arguments.

    NOTE: The instances returned by this method pre-allocate a full array of length numHits.
    Declaration
    public static TopFieldCollector Create(Sort sort, int numHits, bool fillFields, bool trackDocScores, bool trackMaxScore, bool docsScoredInOrder)
    Parameters
    Type Name Description
    Sort sort

    The sort criteria (SortFields).

    int numHits

    The number of results to collect.

    bool fillFields

    Specifies whether the actual field values should be returned on the results (FieldDoc).

    bool 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 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.

    bool trackMaxScore

    Specifies whether the query's maxScore should be tracked and set on the resulting TopDocs. Note that if set to false, MaxScore returns 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.

    bool docsScoredInOrder

    Specifies whether documents are scored in doc Id order or not by the given Scorer in SetScorer(Scorer).

    Returns
    Type Description
    TopFieldCollector

    A TopFieldCollector instance which will sort the results by the sort criteria.

    Exceptions
    Type Condition
    IOException

    If there is a low-level I/O error

    ArgumentNullException

    sort is null.

    NewTopDocs(ScoreDoc[]?, int)

    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(int) or because the arguments to TopDocs were invalid.

    Declaration
    protected override TopDocs NewTopDocs(ScoreDoc[]? results, int start)
    Parameters
    Type Name Description
    ScoreDoc[] results
    int start
    Returns
    Type Description
    TopDocs
    Overrides
    TopDocsCollector<FieldValueHitQueue.Entry>.NewTopDocs(ScoreDoc[], int)

    PopulateResults(ScoreDoc[], int)

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

    Declaration
    protected override void PopulateResults(ScoreDoc[] results, int howMany)
    Parameters
    Type Name Description
    ScoreDoc[] results
    int howMany
    Overrides
    TopDocsCollector<FieldValueHitQueue.Entry>.PopulateResults(ScoreDoc[], int)

    Implements

    ITopDocsCollector
    ICollector
    Back to top Copyright © 2024 The Apache Software Foundation, Licensed under the Apache License, Version 2.0
    Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation.
    All other marks mentioned may be trademarks or registered trademarks of their respective owners.