Class ElasticsearchDirectoryReader
- java.lang.Object
-
- org.apache.lucene.index.IndexReader
-
- org.apache.lucene.index.CompositeReader
-
- org.apache.lucene.index.BaseCompositeReader<LeafReader>
-
- org.apache.lucene.index.DirectoryReader
-
- org.apache.lucene.index.FilterDirectoryReader
-
- org.elasticsearch.common.lucene.index.ElasticsearchDirectoryReader
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public final class ElasticsearchDirectoryReader extends FilterDirectoryReader
AFilterDirectoryReaderthat exposes Elasticsearch internal per shard / index information like the shard ID.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.lucene.index.IndexReader
IndexReader.CacheHelper, IndexReader.CacheKey, IndexReader.ClosedListener
-
-
Field Summary
-
Fields inherited from class org.apache.lucene.index.FilterDirectoryReader
in
-
Fields inherited from class org.apache.lucene.index.DirectoryReader
directory
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidaddReaderCloseListener(DirectoryReader reader, IndexReader.ClosedListener listener)Adds the given listener to the provided directory reader.protected DirectoryReaderdoWrapDirectoryReader(DirectoryReader in)Called by the doOpenIfChanged() methods to return a new wrapped DirectoryReader.static ElasticsearchDirectoryReadergetElasticsearchDirectoryReader(DirectoryReader reader)Tries to unwrap the given reader until the firstElasticsearchDirectoryReaderinstance is found ornullif no instance is found.IndexReader.CacheHelpergetReaderCacheHelper()Optional method: Return aIndexReader.CacheHelperthat can be used to cache based on the content of this reader.ShardIdshardId()Returns the shard id this index belongs to.static ElasticsearchDirectoryReaderwrap(DirectoryReader reader, ShardId shardId)Wraps the given reader in aElasticsearchDirectoryReaderas well as all it's sub-readers inElasticsearchLeafReaderto expose the given shard Id.-
Methods inherited from class org.apache.lucene.index.FilterDirectoryReader
doClose, doOpenIfChanged, doOpenIfChanged, doOpenIfChanged, getDelegate, getIndexCommit, getVersion, isCurrent, unwrap
-
Methods inherited from class org.apache.lucene.index.DirectoryReader
directory, indexExists, listCommits, open, open, open, open, open, open, openIfChanged, openIfChanged, openIfChanged, openIfChanged
-
Methods inherited from class org.apache.lucene.index.BaseCompositeReader
docFreq, document, getDocCount, getSequentialSubReaders, getSumDocFreq, getSumTotalTermFreq, getTermVectors, maxDoc, numDocs, readerBase, readerIndex, totalTermFreq
-
Methods inherited from class org.apache.lucene.index.CompositeReader
getContext, toString
-
Methods inherited from class org.apache.lucene.index.IndexReader
close, decRef, document, document, ensureOpen, equals, getRefCount, getTermVector, hasDeletions, hashCode, incRef, leaves, numDeletedDocs, registerParentReader, tryIncRef
-
-
-
-
Method Detail
-
shardId
public ShardId shardId()
Returns the shard id this index belongs to.
-
getReaderCacheHelper
public IndexReader.CacheHelper getReaderCacheHelper()
Description copied from class:IndexReaderOptional method: Return aIndexReader.CacheHelperthat can be used to cache based on the content of this reader. Two readers that have different data or different sets of deleted documents will be considered different.A return value of
nullindicates that this reader is not suited for caching, which is typically the case for short-lived wrappers that alter the content of the wrapped reader.- Specified by:
getReaderCacheHelperin classIndexReader
-
doWrapDirectoryReader
protected DirectoryReader doWrapDirectoryReader(DirectoryReader in) throws IOException
Description copied from class:FilterDirectoryReaderCalled by the doOpenIfChanged() methods to return a new wrapped DirectoryReader. Implementations should just return an instantiation of themselves, wrapping the passed in DirectoryReader.- Specified by:
doWrapDirectoryReaderin classFilterDirectoryReader- Parameters:
in- the DirectoryReader to wrap- Returns:
- the wrapped DirectoryReader
- Throws:
IOException
-
wrap
public static ElasticsearchDirectoryReader wrap(DirectoryReader reader, ShardId shardId) throws IOException
Wraps the given reader in aElasticsearchDirectoryReaderas well as all it's sub-readers inElasticsearchLeafReaderto expose the given shard Id.- Parameters:
reader- the reader to wrapshardId- the shard ID to expose via the elasticsearch internal reader wrappers.- Throws:
IOException
-
addReaderCloseListener
public static void addReaderCloseListener(DirectoryReader reader, IndexReader.ClosedListener listener)
Adds the given listener to the provided directory reader. The reader must contain anElasticsearchDirectoryReaderin it's hierarchy otherwise we can't safely install the listener.- Throws:
IllegalArgumentException- if the reader doesn't contain anElasticsearchDirectoryReaderin it's hierarchy
-
getElasticsearchDirectoryReader
public static ElasticsearchDirectoryReader getElasticsearchDirectoryReader(DirectoryReader reader)
Tries to unwrap the given reader until the firstElasticsearchDirectoryReaderinstance is found ornullif no instance is found.
-
-