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.4Inherited Members
Namespace: Lucene.Net.Search
Assembly: Lucene.Net.dll
Syntax
public class FilteredQuery : Query
Constructors
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 |
Filter | filter | Filter to apply to query results, cannot be |
See Also
FilteredQuery(Query, Filter, 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 |
Filter | filter | Filter to apply to query results, cannot be |
FilteredQuery.FilterStrategy | strategy | A filter strategy used to create a filtered scorer. |
See Also
Fields
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 |
See Also
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 |
See Also
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 |
See Also
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, int) 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 |
See Also
Properties
Filter
Returns this FilteredQuery's filter
Declaration
public Filter Filter { get; }
Property Value
Type | Description |
---|---|
Filter |
See Also
Query
Returns this FilteredQuery's (unfiltered) Query
Declaration
public Query Query { get; }
Property Value
Type | Description |
---|---|
Query |
See Also
Strategy
Returns this FilteredQuery's FilteredQuery.FilterStrategy
Declaration
public virtual FilteredQuery.FilterStrategy Strategy { get; }
Property Value
Type | Description |
---|---|
FilteredQuery.FilterStrategy |
See Also
Methods
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
See Also
Equals(object)
Returns true if o
is equal to this.
Declaration
public override bool Equals(object o)
Parameters
Type | Name | Description |
---|---|---|
object | o |
Returns
Type | Description |
---|---|
bool |
Overrides
See Also
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
Exceptions
Type | Condition |
---|---|
InvalidOperationException | If this query is not yet rewritten |
See Also
GetHashCode()
Returns a hash code value for this object.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int |
Overrides
See Also
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
See Also
ToString(string)
Prints a user-readable version of this query.
Declaration
public override string ToString(string s)
Parameters
Type | Name | Description |
---|---|---|
string | s |
Returns
Type | Description |
---|---|
string |