org.apache.lucene.search

## Class Filter

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

- All Implemented Interfaces:
    Cloneable
  Direct Known Subclasses:
    CachingWrapperFilter, FieldValueFilter, MultiTermQueryWrapperFilter, QueryWrapperFilter

  Deprecated.
  Use `Query` objects instead: when queries are wrapped in a `ConstantScoreQuery` or in a `BooleanClause.Occur.FILTER` clause, they automatically disable the score computation so the `Filter` class does not provide benefits compared to queries anymore.

      @Deprecated
      public abstract class Filter
      extends Query

  Convenient base class for building queries that only perform matching, but no scoring. The scorer produced by such queries always returns 0 as score.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Filter()` Deprecated.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract DocIdSet` | `getDocIdSet(LeafReaderContext context, Bits acceptDocs)` Deprecated. Creates a `DocIdSet` enumerating the documents that should be permitted in search results.
    `Query` | `rewrite(IndexReader reader)` Deprecated. Expert: called to re-write queries into primitive queries.

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

      `clone, createWeight, equals, getBoost, hashCode, setBoost, toString, toString`

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

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

- - ### Constructor Detail

    - #### Filter

          public Filter()

      Deprecated.

  - ### Method Detail

    - #### getDocIdSet

          public abstract DocIdSet getDocIdSet(LeafReaderContext context,
                             Bits acceptDocs)
                                        throws IOException

      Deprecated.
      Creates a `DocIdSet` enumerating the documents that should be permitted in search results. NOTE: null can be returned if no documents are accepted by this Filter.

      Note: This method will be called once per segment in the index during searching. The returned `DocIdSet` must refer to document IDs for that segment, not for the top-level reader.

      Parameters:
        `context` - a `LeafReaderContext` instance opened on the index currently searched on. Note, it is likely that the provided reader info does not represent the whole underlying index i.e. if the index has more than one segment the given reader only represents a single segment. The provided context is always an atomic context, so you can call `LeafReader.fields()` on the context's reader, for example.
        `acceptDocs` - Bits that represent the allowable docs to match (typically deleted docs but possibly filtering other documents)
      Returns:
        a DocIdSet that provides the documents which should be permitted or prohibited in search results. NOTE: `null` should be returned if the filter doesn't accept any documents otherwise internal optimization might not apply in the case an empty `DocIdSet` is returned.
      Throws:
        `IOException`

    - #### 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`

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