Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class FacetsCollector

    Collects hits for subsequent faceting. Once you've run a search and collect hits into this, instantiate one of the Lucene.Net.Search.ICollector subclasses to do the facet counting. Use the Search utility methods (such as Search(IndexSearcher, Query, int, ICollector)) to perform an "ordinary" search but also collect into a Facets.

    Inheritance
    object
    FacetsCollector
    RandomSamplingFacetsCollector
    Implements
    ICollector
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Lucene.Net.Facet
    Assembly: Lucene.Net.Facet.dll
    Syntax
    public class FacetsCollector : ICollector

    Constructors

    FacetsCollector()

    Default constructor

    Declaration
    public FacetsCollector()

    FacetsCollector(bool)

    Create this; if keepScores is true then a float[] is allocated to hold score of all hits.

    Declaration
    public FacetsCollector(bool keepScores)
    Parameters
    Type Name Description
    bool keepScores

    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 Lucene.Net.Search.BooleanQuery) can achieve faster searching if the Lucene.Net.Search.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 bool AcceptsDocsOutOfOrder { get; }
    Property Value
    Type Description
    bool

    KeepScores

    True if scores were saved.

    Declaration
    public bool KeepScores { get; }
    Property Value
    Type Description
    bool

    Methods

    Collect(int)

    Called once for every document matching a query, with the unbased document number.

    Note: The collection of the current segment can be terminated by throwing a Lucene.Net.Search.CollectionTerminatedException. In this case, the last docs of the current Lucene.Net.Index.AtomicReaderContext will be skipped and Lucene.Net.Search.IndexSearcher will swallow the exception and continue collection with the next leaf.

    Note: this is called in an inner search loop. For good search performance, implementations of this method should not call Doc(int) or Document(int) on every hit. Doing so can slow searches by an order of magnitude or more.
    Declaration
    public void Collect(int doc)
    Parameters
    Type Name Description
    int doc

    CreateDocs(int)

    Creates a FacetsCollector.Docs to record hits. The default uses Lucene.Net.Util.FixedBitSet to record hits and you can override to e.g. record the docs in your own Lucene.Net.Search.DocIdSet.

    Declaration
    protected virtual FacetsCollector.Docs CreateDocs(int maxDoc)
    Parameters
    Type Name Description
    int maxDoc
    Returns
    Type Description
    FacetsCollector.Docs

    GetMatchingDocs()

    Returns the documents matched by the query, one FacetsCollector.MatchingDocs per visited segment.

    Declaration
    public virtual IList<FacetsCollector.MatchingDocs> GetMatchingDocs()
    Returns
    Type Description
    IList<FacetsCollector.MatchingDocs>

    Search(IndexSearcher, Query, Filter, int, ICollector)

    Utility method, to search and also collect all hits into the provided Lucene.Net.Search.ICollector.

    Declaration
    public static TopDocs Search(IndexSearcher searcher, Query q, Filter filter, int n, ICollector fc)
    Parameters
    Type Name Description
    IndexSearcher searcher
    Query q
    Filter filter
    int n
    ICollector fc
    Returns
    Type Description
    TopDocs

    Search(IndexSearcher, Query, Filter, int, Sort, ICollector)

    Utility method, to search and also collect all hits into the provided Lucene.Net.Search.ICollector.

    Declaration
    public static TopFieldDocs Search(IndexSearcher searcher, Query q, Filter filter, int n, Sort sort, ICollector fc)
    Parameters
    Type Name Description
    IndexSearcher searcher
    Query q
    Filter filter
    int n
    Sort sort
    ICollector fc
    Returns
    Type Description
    TopFieldDocs

    Search(IndexSearcher, Query, Filter, int, Sort, bool, bool, ICollector)

    Utility method, to search and also collect all hits into the provided Lucene.Net.Search.ICollector.

    Declaration
    public static TopFieldDocs Search(IndexSearcher searcher, Query q, Filter filter, int n, Sort sort, bool doDocScores, bool doMaxScore, ICollector fc)
    Parameters
    Type Name Description
    IndexSearcher searcher
    Query q
    Filter filter
    int n
    Sort sort
    bool doDocScores
    bool doMaxScore
    ICollector fc
    Returns
    Type Description
    TopFieldDocs

    Search(IndexSearcher, Query, int, ICollector)

    Utility method, to search and also collect all hits into the provided Lucene.Net.Search.ICollector.

    Declaration
    public static TopDocs Search(IndexSearcher searcher, Query q, int n, ICollector fc)
    Parameters
    Type Name Description
    IndexSearcher searcher
    Query q
    int n
    ICollector fc
    Returns
    Type Description
    TopDocs

    SearchAfter(IndexSearcher, ScoreDoc, Query, Filter, int, ICollector)

    Utility method, to search and also collect all hits into the provided Lucene.Net.Search.ICollector.

    Declaration
    public static TopDocs SearchAfter(IndexSearcher searcher, ScoreDoc after, Query q, Filter filter, int n, ICollector fc)
    Parameters
    Type Name Description
    IndexSearcher searcher
    ScoreDoc after
    Query q
    Filter filter
    int n
    ICollector fc
    Returns
    Type Description
    TopDocs

    SearchAfter(IndexSearcher, ScoreDoc, Query, Filter, int, Sort, ICollector)

    Utility method, to search and also collect all hits into the provided Lucene.Net.Search.ICollector.

    Declaration
    public static TopDocs SearchAfter(IndexSearcher searcher, ScoreDoc after, Query q, Filter filter, int n, Sort sort, ICollector fc)
    Parameters
    Type Name Description
    IndexSearcher searcher
    ScoreDoc after
    Query q
    Filter filter
    int n
    Sort sort
    ICollector fc
    Returns
    Type Description
    TopDocs

    SearchAfter(IndexSearcher, ScoreDoc, Query, Filter, int, Sort, bool, bool, ICollector)

    Utility method, to search and also collect all hits into the provided Lucene.Net.Search.ICollector.

    Declaration
    public static TopDocs SearchAfter(IndexSearcher searcher, ScoreDoc after, Query q, Filter filter, int n, Sort sort, bool doDocScores, bool doMaxScore, ICollector fc)
    Parameters
    Type Name Description
    IndexSearcher searcher
    ScoreDoc after
    Query q
    Filter filter
    int n
    Sort sort
    bool doDocScores
    bool doMaxScore
    ICollector fc
    Returns
    Type Description
    TopDocs

    SearchAfter(IndexSearcher, ScoreDoc, Query, int, ICollector)

    Utility method, to search and also collect all hits into the provided Lucene.Net.Search.ICollector.

    Declaration
    public virtual TopDocs SearchAfter(IndexSearcher searcher, ScoreDoc after, Query q, int n, ICollector fc)
    Parameters
    Type Name Description
    IndexSearcher searcher
    ScoreDoc after
    Query q
    int n
    ICollector fc
    Returns
    Type Description
    TopDocs

    SetNextReader(AtomicReaderContext)

    Called before collecting from each Lucene.Net.Index.AtomicReaderContext. All doc ids in Collect(int) will correspond to Lucene.Net.Index.IndexReaderContext.Reader.

    Add Lucene.Net.Index.AtomicReaderContext.DocBase to the current Lucene.Net.Index.IndexReaderContext.Reader's internal document id to re-base ids in Collect(int).
    Declaration
    public void SetNextReader(AtomicReaderContext context)
    Parameters
    Type Name Description
    AtomicReaderContext context

    next atomic reader context

    SetScorer(Scorer)

    Called before successive calls to Collect(int). Implementations that need the score of the current document (passed-in to Collect(int)), should save the passed-in Lucene.Net.Search.Scorer and call scorer.GetScore() when needed.

    Declaration
    public void SetScorer(Scorer scorer)
    Parameters
    Type Name Description
    Scorer scorer

    Implements

    Lucene.Net.Search.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.