public class

CachingWrapperFilter

extends Filter
java.lang.Object
   ↳ org.apache.lucene.search.Filter
     ↳ org.apache.lucene.search.CachingWrapperFilter

Class Overview

Wraps another filter's result and caches it. The purpose is to allow filters to simply filter, and then wrap with this class to add caching.

Summary

Nested Classes
enum CachingWrapperFilter.DeletesMode Expert: Specifies how new deletions against a reopened reader should be handled. 
Fields
protected final FilterCache<DocIdSet> cache
Public Constructors
CachingWrapperFilter(Filter filter)
New deletes are ignored by default, which gives higher cache hit rate on reopened readers.
CachingWrapperFilter(Filter filter, CachingWrapperFilter.DeletesMode deletesMode)
Expert: by default, the cached filter will be shared across reopened segments that only had changes to their deletions.
Public Methods
boolean equals(Object o)
DocIdSet getDocIdSet(IndexReader reader)
Creates a DocIdSet enumerating the documents that should be permitted in search results.
int hashCode()
String toString()
Protected Methods
DocIdSet docIdSetToCache(DocIdSet docIdSet, IndexReader reader)
Provide the DocIdSet to be cached, using the DocIdSet provided by the wrapped Filter.
[Expand]
Inherited Methods
From class org.apache.lucene.search.Filter
From class java.lang.Object

Fields

protected final FilterCache<DocIdSet> cache

Public Constructors

public CachingWrapperFilter (Filter filter)

New deletes are ignored by default, which gives higher cache hit rate on reopened readers. Most of the time this is safe, because the filter will be AND'd with a Query that fully enforces deletions. If instead you need this filter to always enforce deletions, pass either RECACHE or DYNAMIC.

Parameters
filter Filter to cache results of

public CachingWrapperFilter (Filter filter, CachingWrapperFilter.DeletesMode deletesMode)

Expert: by default, the cached filter will be shared across reopened segments that only had changes to their deletions.

Parameters
filter Filter to cache results of
deletesMode See CachingWrapperFilter.DeletesMode

Public Methods

public boolean equals (Object o)

public DocIdSet getDocIdSet (IndexReader reader)

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
reader a IndexReader instance opened on the index currently searched on. Note, it is likely that the provided reader 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.
Returns
  • a DocIdSet that provides the documents which should be permitted or prohibited in search results. NOTE: null can be returned if no documents will be accepted by this Filter.
Throws
IOException

public int hashCode ()

public String toString ()

Protected Methods

protected DocIdSet docIdSetToCache (DocIdSet docIdSet, IndexReader reader)

Provide the DocIdSet to be cached, using the DocIdSet provided by the wrapped Filter.

This implementation returns the given DocIdSet, if isCacheable() returns true, else it copies the DocIdSetIterator into an OpenBitSetDISI.

Throws
IOException