Class FilteredQuery

java.lang.Object
org.apache.lucene.search.Query
org.apache.lucene.search.FilteredQuery
All Implemented Interfaces:
Cloneable

public class FilteredQuery extends Query
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
See Also:
  • Field Details

    • RANDOM_ACCESS_FILTER_STRATEGY

      public static final 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 DocIdSet.bits()) and FilteredQuery.RandomAccessFilterStrategy.useRandomAccess(Bits, 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

    • LEAP_FROG_FILTER_FIRST_STRATEGY

      public static final FilteredQuery.FilterStrategy 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.

    • LEAP_FROG_QUERY_FIRST_STRATEGY

      public static final 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.

    • QUERY_FIRST_FILTER_STRATEGY

      public static final 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 DocIdSet.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.

  • Constructor Details

  • Method Details