org.apache.lucene.search

## Class FilteredQuery

- java.lang.Object
- - org.apache.lucene.search.Query
  - - org.apache.lucene.search.FilteredQuery

- All Implemented Interfaces:
    Cloneable

  Deprecated.
  FilteredQuery will be removed in Lucene 6.0. It should be replaced with a `BooleanQuery` with one `BooleanClause.Occur.MUST` clause for the query and one `BooleanClause.Occur.FILTER` clause for the filter.

      @Deprecated
      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:
    `CachingWrapperQuery`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `FilteredQuery.FilterStrategy` Deprecated. Abstract class that defines how the filter (`DocIdSet`) applied during document collection.
    `static class` | `FilteredQuery.RandomAccessFilterStrategy` Deprecated. 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, long)` returns `true`.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static FilteredQuery.FilterStrategy` | `LEAP_FROG_FILTER_FIRST_STRATEGY` Deprecated. A filter strategy that uses a "leap-frog" approach (also called "zig-zag join").
    `static FilteredQuery.FilterStrategy` | `LEAP_FROG_QUERY_FIRST_STRATEGY` Deprecated. A filter strategy that uses a "leap-frog" approach (also called "zig-zag join").
    `static FilteredQuery.FilterStrategy` | `QUERY_FIRST_FILTER_STRATEGY` Deprecated. A filter strategy that advances the Query or rather its `Scorer` first and consults the filter `DocIdSet` for each matched document.
    `static FilteredQuery.FilterStrategy` | `RANDOM_ACCESS_FILTER_STRATEGY` Deprecated. 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, long)` returns `true`.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FilteredQuery(Query query, Filter filter)` Deprecated. Constructs a new query which applies a filter to the results of the original query.
    `FilteredQuery(Query query, Filter filter, FilteredQuery.FilterStrategy strategy)` Deprecated. Expert: Constructs a new query which applies a filter to the results of the original query.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object o)` Deprecated. Returns true iff `o` is equal to this.
    `Filter` | `getFilter()` Deprecated. Returns this FilteredQuery's filter
    `FilteredQuery.FilterStrategy` | `getFilterStrategy()` Deprecated. Returns this FilteredQuery's `FilteredQuery.FilterStrategy`
    `Query` | `getQuery()` Deprecated. Returns this FilteredQuery's (unfiltered) Query
    `int` | `hashCode()` Deprecated. Returns a hash code value for this object.
    `Query` | `rewrite(IndexReader reader)` Deprecated. Expert: called to re-write queries into primitive queries.
    `String` | `toString(String s)` Deprecated. Prints a user-readable version of this query.

    - ### Methods inherited from class org.apache.lucene.search.Query

      `clone, createWeight, getBoost, setBoost, toString`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### RANDOM_ACCESS_FILTER_STRATEGY

          public static final FilteredQuery.FilterStrategy RANDOM_ACCESS_FILTER_STRATEGY

      Deprecated.
      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, long)` 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

      Deprecated.
      A filter strategy that uses a "leap-frog" approach (also called "zig-zag join"). In spite of the name of this constant, which one will be iterated first depends on the `cost` of the filter compared to the query.

    - #### LEAP_FROG_QUERY_FIRST_STRATEGY

          public static final FilteredQuery.FilterStrategy LEAP_FROG_QUERY_FIRST_STRATEGY

      Deprecated.
      A filter strategy that uses a "leap-frog" approach (also called "zig-zag join"). In spite of the name of this constant, which one will be iterated first depends on the `cost` of the filter compared to the query.

    - #### QUERY_FIRST_FILTER_STRATEGY

          public static final FilteredQuery.FilterStrategy QUERY_FIRST_FILTER_STRATEGY

      Deprecated.
      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 Detail

    - #### FilteredQuery

          public FilteredQuery(Query query,
                       Filter filter)

      Deprecated.
      Constructs a new query which applies a filter to the results of the original query. `Filter.getDocIdSet(org.apache.lucene.index.LeafReaderContext, org.apache.lucene.util.Bits)` will be called every time this query is used in a search.
      Parameters:
        `query` - Query to be filtered, cannot be `null`.
        `filter` - Filter to apply to query results, cannot be `null`.

    - #### FilteredQuery

          public FilteredQuery(Query query,
                       Filter filter,
                       FilteredQuery.FilterStrategy strategy)

      Deprecated.
      Expert: Constructs a new query which applies a filter to the results of the original query. `Filter.getDocIdSet(org.apache.lucene.index.LeafReaderContext, org.apache.lucene.util.Bits)` will be called every time this query is used in a search.
      Parameters:
        `query` - Query to be filtered, cannot be `null`.
        `filter` - Filter to apply to query results, cannot be `null`.
        `strategy` - a filter strategy used to create a filtered scorer.
      See Also:
        `FilteredQuery.FilterStrategy`

  - ### Method Detail

    - #### rewrite

          public Query rewrite(IndexReader reader)
                        throws IOException

      Deprecated.
      Description copied from class: `Query`
      Expert: called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into a BooleanQuery that consists of TermQuerys.
      Overrides:
        `rewrite` in class `Query`
      Throws:
        `IOException`

    - #### getQuery

          public final Query getQuery()

      Deprecated.
      Returns this FilteredQuery's (unfiltered) Query

    - #### getFilter

          public final Filter getFilter()

      Deprecated.
      Returns this FilteredQuery's filter

    - #### getFilterStrategy

          public FilteredQuery.FilterStrategy getFilterStrategy()

      Deprecated.
      Returns this FilteredQuery's `FilteredQuery.FilterStrategy`

    - #### toString

          public String toString(String s)

      Deprecated.
      Prints a user-readable version of this query.
      Specified by:
        `toString` in class `Query`

    - #### equals

          public boolean equals(Object o)

      Deprecated.
      Returns true iff `o` is equal to this.
      Overrides:
        `equals` in class `Query`

    - #### hashCode

          public int hashCode()

      Deprecated.
      Returns a hash code value for this object.
      Overrides:
        `hashCode` in class `Query`

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.