Class FilterDirectoryReader
- java.lang.Object
-
- org.apache.lucene.index.IndexReader
-
- org.apache.lucene.index.CompositeReader
-
- org.apache.lucene.index.BaseCompositeReader<AtomicReader>
-
- org.apache.lucene.index.DirectoryReader
-
- org.apache.lucene.index.FilterDirectoryReader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public abstract class FilterDirectoryReader extends DirectoryReader
A FilterDirectoryReader wraps another DirectoryReader, allowing implementations to transform or extend it. Subclasses should implement doWrapDirectoryReader to return an instance of the subclass. If the subclass wants to wrap the DirectoryReader's subreaders, it should also implement a SubReaderWrapper subclass, and pass an instance to its super constructor.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FilterDirectoryReader.StandardReaderWrapper
A no-op SubReaderWrapper that simply returns the parent DirectoryReader's original subreaders.static class
FilterDirectoryReader.SubReaderWrapper
Factory class passed to FilterDirectoryReader constructor that allows subclasses to wrap the filtered DirectoryReader's subreaders.-
Nested classes/interfaces inherited from class org.apache.lucene.index.IndexReader
IndexReader.ReaderClosedListener
-
-
Field Summary
-
Fields inherited from class org.apache.lucene.index.DirectoryReader
DEFAULT_TERMS_INDEX_DIVISOR
-
-
Constructor Summary
Constructors Constructor Description FilterDirectoryReader(DirectoryReader in)
Create a new FilterDirectoryReader that filters a passed in DirectoryReader.FilterDirectoryReader(DirectoryReader in, FilterDirectoryReader.SubReaderWrapper wrapper)
Create a new FilterDirectoryReader that filters a passed in DirectoryReader, using the supplied SubReaderWrapper to wrap its subreader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IndexCommit
getIndexCommit()
Expert: return the IndexCommit that this reader has opened.long
getVersion()
Version number when this IndexReader was opened.boolean
isCurrent()
Check whether any new changes have occurred to the index since this reader was opened.-
Methods inherited from class org.apache.lucene.index.DirectoryReader
directory, indexExists, listCommits, open, open, open, open, open, openIfChanged, openIfChanged, openIfChanged
-
Methods inherited from class org.apache.lucene.index.BaseCompositeReader
docFreq, document, getDocCount, getSumDocFreq, getSumTotalTermFreq, getTermVectors, maxDoc, numDocs, totalTermFreq
-
Methods inherited from class org.apache.lucene.index.CompositeReader
getContext, toString
-
Methods inherited from class org.apache.lucene.index.IndexReader
addReaderClosedListener, close, decRef, document, document, equals, getCombinedCoreAndDeletesKey, getCoreCacheKey, getRefCount, getTermVector, hasDeletions, hashCode, incRef, leaves, numDeletedDocs, registerParentReader, removeReaderClosedListener, tryIncRef
-
-
-
-
Constructor Detail
-
FilterDirectoryReader
public FilterDirectoryReader(DirectoryReader in)
Create a new FilterDirectoryReader that filters a passed in DirectoryReader.- Parameters:
in
- the DirectoryReader to filter
-
FilterDirectoryReader
public FilterDirectoryReader(DirectoryReader in, FilterDirectoryReader.SubReaderWrapper wrapper)
Create a new FilterDirectoryReader that filters a passed in DirectoryReader, using the supplied SubReaderWrapper to wrap its subreader.- Parameters:
in
- the DirectoryReader to filterwrapper
- the SubReaderWrapper to use to wrap subreaders
-
-
Method Detail
-
getVersion
public long getVersion()
Description copied from class:DirectoryReader
Version number when this IndexReader was opened.This method returns the version recorded in the commit that the reader opened. This version is advanced every time a change is made with
IndexWriter
.- Specified by:
getVersion
in classDirectoryReader
-
isCurrent
public boolean isCurrent() throws java.io.IOException
Description copied from class:DirectoryReader
Check whether any new changes have occurred to the index since this reader was opened.If this reader was created by calling
DirectoryReader.open(org.apache.lucene.store.Directory)
, then this method checks if any further commits (seeIndexWriter.commit()
) have occurred in the directory.If instead this reader is a near real-time reader (ie, obtained by a call to
DirectoryReader.open(IndexWriter,boolean)
, or by callingDirectoryReader.openIfChanged(org.apache.lucene.index.DirectoryReader)
on a near real-time reader), then this method checks if either a new commit has occurred, or any new uncommitted changes have taken place via the writer. Note that even if the writer has only performed merging, this method will still return false.In any event, if this returns false, you should call
DirectoryReader.openIfChanged(org.apache.lucene.index.DirectoryReader)
to get a new reader that sees the changes.- Specified by:
isCurrent
in classDirectoryReader
- Throws:
java.io.IOException
- if there is a low-level IO error
-
getIndexCommit
public IndexCommit getIndexCommit() throws java.io.IOException
Description copied from class:DirectoryReader
Expert: return the IndexCommit that this reader has opened.- Specified by:
getIndexCommit
in classDirectoryReader
- Throws:
java.io.IOException
-
-