org.apache.lucene.search

## Class FilteredQuery.RandomAccessFilterStrategy

- java.lang.Object
- - org.apache.lucene.search.FilteredQuery.FilterStrategy
  - - org.apache.lucene.search.FilteredQuery.RandomAccessFilterStrategy

- Enclosing class:
    FilteredQuery

      public static class FilteredQuery.RandomAccessFilterStrategy
      extends FilteredQuery.FilterStrategy

  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 `useRandomAccess(Bits, long)` returns `true`. Otherwise this strategy falls back to a "zig-zag join" ( `FilteredQuery.LEAP_FROG_FILTER_FIRST_STRATEGY`) strategy .

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FilteredQuery.RandomAccessFilterStrategy()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Query` | `rewrite(Filter filter)` Rewrite the filter.
    `protected boolean` | `useRandomAccess(Bits bits, long filterCost)` Expert: decides if a filter should be executed as "random-access" or not.

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### FilteredQuery.RandomAccessFilterStrategy

          public FilteredQuery.RandomAccessFilterStrategy()

  - ### Method Detail

    - #### rewrite

          public Query rewrite(Filter filter)

      Description copied from class: `FilteredQuery.FilterStrategy`
      Rewrite the filter.
      Specified by:
        `rewrite` in class `FilteredQuery.FilterStrategy`

    - #### useRandomAccess

          protected boolean useRandomAccess(Bits bits,
                                long filterCost)

      Expert: decides if a filter should be executed as "random-access" or not. random-access means the filter "filters" in a similar way as deleted docs are filtered in Lucene. This is faster when the filter accepts many documents. However, when the filter is very sparse, it can be faster to execute the query+filter as a conjunction in some cases. The default implementation returns `true` if the filter matches more than 1% of documents
      NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

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