Show / Hide Table of Contents

    Class FilteredQuery

    A query that applies a filter to the results of another query.

    Note: the bits are retrieved from the filter each time this query is used in a search - use a CachingWrapperFilter to avoid regenerating the bits every time.

    @since 1.4

    Inheritance
    System.Object
    Query
    FilteredQuery
    Inherited Members
    Query.Boost
    Query.ToString()
    Query.Clone()
    Namespace: Lucene.Net.Search
    Assembly: Lucene.Net.dll
    Syntax
    public class FilteredQuery : Query

    Constructors

    | Improve this Doc View Source

    FilteredQuery(Query, Filter)

    Constructs a new query which applies a filter to the results of the original query. GetDocIdSet(AtomicReaderContext, IBits) will be called every time this query is used in a search.

    Declaration
    public FilteredQuery(Query query, Filter filter)
    Parameters
    Type Name Description
    Query query

    Query to be filtered, cannot be null.

    Filter filter

    Filter to apply to query results, cannot be null.

    | Improve this Doc View Source

    FilteredQuery(Query, Filter, FilteredQuery.FilterStrategy)

    Expert: Constructs a new query which applies a filter to the results of the original query. GetDocIdSet(AtomicReaderContext, IBits) will be called every time this query is used in a search.

    Declaration
    public FilteredQuery(Query query, Filter filter, FilteredQuery.FilterStrategy strategy)
    Parameters
    Type Name Description
    Query query

    Query to be filtered, cannot be null.

    Filter filter

    Filter to apply to query results, cannot be null.

    FilteredQuery.FilterStrategy strategy

    A filter strategy used to create a filtered scorer.

    See Also
    FilteredQuery.FilterStrategy

    Fields

    | Improve this Doc View Source

    LEAP_FROG_FILTER_FIRST_STRATEGY

    A filter strategy that uses a "leap-frog" approach (also called "zig-zag join"). The scorer and the filter take turns trying to advance to each other's next matching document, often jumping past the target document. When both land on the same document, it's collected.

    Note: this strategy uses the filter to lead the iteration.

    Declaration
    public static readonly FilteredQuery.FilterStrategy LEAP_FROG_FILTER_FIRST_STRATEGY
    Field Value
    Type Description
    FilteredQuery.FilterStrategy
    | Improve this Doc View Source

    LEAP_FROG_QUERY_FIRST_STRATEGY

    A filter strategy that uses a "leap-frog" approach (also called "zig-zag join"). The scorer and the filter take turns trying to advance to each other's next matching document, often jumping past the target document. When both land on the same document, it's collected.

    Note: this strategy uses the query to lead the iteration.

    Declaration
    public static readonly FilteredQuery.FilterStrategy LEAP_FROG_QUERY_FIRST_STRATEGY
    Field Value
    Type Description
    FilteredQuery.FilterStrategy
    | Improve this Doc View Source

    QUERY_FIRST_FILTER_STRATEGY

    A filter strategy that advances the Query or rather its Scorer first and consults the filter DocIdSet for each matched document.

    Note: this strategy requires a Bits to return a non-null value. Otherwise this strategy falls back to LEAP_FROG_QUERY_FIRST_STRATEGY

    Use this strategy if the filter computation is more expensive than document scoring or if the filter has a linear running time to compute the next matching doc like exact geo distances.

    Declaration
    public static readonly FilteredQuery.FilterStrategy QUERY_FIRST_FILTER_STRATEGY
    Field Value
    Type Description
    FilteredQuery.FilterStrategy
    | Improve this Doc View Source

    RANDOM_ACCESS_FILTER_STRATEGY

    A FilteredQuery.FilterStrategy that conditionally uses a random access filter if the given DocIdSet supports random access (returns a non-null value from Bits) and UseRandomAccess(IBits, Int32) returns true. Otherwise this strategy falls back to a "zig-zag join" ( LEAP_FROG_FILTER_FIRST_STRATEGY) strategy.

    Note: this strategy is the default strategy in FilteredQuery

    Declaration
    public static readonly FilteredQuery.FilterStrategy RANDOM_ACCESS_FILTER_STRATEGY
    Field Value
    Type Description
    FilteredQuery.FilterStrategy

    Properties

    | Improve this Doc View Source

    Filter

    Returns this FilteredQuery's filter

    Declaration
    public Filter Filter { get; }
    Property Value
    Type Description
    Filter
    | Improve this Doc View Source

    Query

    Returns this FilteredQuery's (unfiltered) Query

    Declaration
    public Query Query { get; }
    Property Value
    Type Description
    Query
    | Improve this Doc View Source

    Strategy

    Returns this FilteredQuery's FilteredQuery.FilterStrategy

    Declaration
    public virtual FilteredQuery.FilterStrategy Strategy { get; }
    Property Value
    Type Description
    FilteredQuery.FilterStrategy

    Methods

    | Improve this Doc View Source

    CreateWeight(IndexSearcher)

    Returns a Weight that applies the filter to the enclosed query's Weight. this is accomplished by overriding the Scorer returned by the Weight.

    Declaration
    public override Weight CreateWeight(IndexSearcher searcher)
    Parameters
    Type Name Description
    IndexSearcher searcher
    Returns
    Type Description
    Weight
    Overrides
    Query.CreateWeight(IndexSearcher)
    | Improve this Doc View Source

    Equals(Object)

    Returns true if o is equal to this.

    Declaration
    public override bool Equals(object o)
    Parameters
    Type Name Description
    System.Object o
    Returns
    Type Description
    System.Boolean
    Overrides
    Query.Equals(Object)
    | Improve this Doc View Source

    ExtractTerms(ISet<Term>)

    Expert: adds all terms occurring in this query to the terms set. Only works if this query is in its rewritten (Rewrite(IndexReader)) form.

    Declaration
    public override void ExtractTerms(ISet<Term> terms)
    Parameters
    Type Name Description
    ISet<Term> terms
    Overrides
    Query.ExtractTerms(ISet<Term>)
    | Improve this Doc View Source

    GetHashCode()

    Returns a hash code value for this object.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    System.Int32
    Overrides
    Query.GetHashCode()
    | Improve this Doc View Source

    Rewrite(IndexReader)

    Rewrites the query. If the wrapped is an instance of MatchAllDocsQuery it returns a ConstantScoreQuery. Otherwise it returns a new FilteredQuery wrapping the rewritten query.

    Declaration
    public override Query Rewrite(IndexReader reader)
    Parameters
    Type Name Description
    IndexReader reader
    Returns
    Type Description
    Query
    Overrides
    Query.Rewrite(IndexReader)
    | Improve this Doc View Source

    ToString(String)

    Prints a user-readable version of this query.

    Declaration
    public override string ToString(string s)
    Parameters
    Type Name Description
    System.String s
    Returns
    Type Description
    System.String
    Overrides
    Query.ToString(String)

    See Also

    CachingWrapperFilter
    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)