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
Namespace: Lucene.Net.Search
Assembly: Lucene.Net.dll
Syntax
public class FilteredQuery : Query
Constructors
| Improve this Doc View SourceFilteredQuery(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 |
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 |
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
| Improve this Doc View SourceLEAP_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 |
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 |
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 |
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 SourceFilter
Returns this FilteredQuery's filter
Declaration
public Filter Filter { get; }
Property Value
Type | Description |
---|---|
Filter |
Query
Returns this FilteredQuery's (unfiltered) Query
Declaration
public Query Query { get; }
Property Value
Type | Description |
---|---|
Query |
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 SourceCreateWeight(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
| Improve this Doc View SourceEquals(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
| Improve this Doc View SourceExtractTerms(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
| Improve this Doc View SourceGetHashCode()
Returns a hash code value for this object.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
Overrides
| Improve this Doc View SourceRewrite(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
| Improve this Doc View SourceToString(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 |