public abstract class LeafReader extends IndexReader
LeafReader is an abstract class, providing an interface for accessing an
index. Search of an index is done entirely through this abstract interface,
so that any subclass which implements it is searchable. IndexReaders implemented
by this subclass do not consist of several sub-readers,
they are atomic. They support retrieval of stored fields, doc values, terms,
and postings.
For efficiency, in this API documents are often referred to via document numbers, non-negative integers which each name a unique document in the index. These document numbers are ephemeral -- they may change as documents are added to and deleted from an index. Clients should thus not rely on a given document having the same number between sessions.
NOTE: IndexReader instances are completely thread
safe, meaning multiple threads can call any of its methods,
concurrently. If your application requires external
synchronization, you should not synchronize on the
IndexReader instance; use your own
(non-Lucene) objects instead.
IndexReader.CacheHelper, IndexReader.CacheKey, IndexReader.ClosedListener| Modifier | Constructor and Description |
|---|---|
protected |
LeafReader()
Sole constructor.
|
| Modifier and Type | Method and Description |
|---|---|
abstract void |
checkIntegrity()
Checks consistency of this reader.
|
int |
docFreq(Term term)
Returns the number of documents containing the
term. |
abstract BinaryDocValues |
getBinaryDocValues(String field)
Returns
BinaryDocValues for this field, or
null if no binary doc values were indexed for
this field. |
LeafReaderContext |
getContext()
Expert: Returns the root
IndexReaderContext for this
IndexReader's sub-reader tree. |
abstract IndexReader.CacheHelper |
getCoreCacheHelper()
Optional method: Return a
IndexReader.CacheHelper that can be used to cache
based on the content of this leaf regardless of deletions. |
int |
getDocCount(String field)
Returns the number of documents that have at least one term for this field.
|
abstract FieldInfos |
getFieldInfos()
Get the
FieldInfos describing all fields in
this reader. |
abstract Bits |
getLiveDocs()
Returns the
Bits representing live (not
deleted) docs. |
abstract LeafMetaData |
getMetaData()
Return metadata about this leaf.
|
abstract NumericDocValues |
getNormValues(String field)
Returns
NumericDocValues representing norms
for this field, or null if no NumericDocValues
were indexed. |
abstract NumericDocValues |
getNumericDocValues(String field)
Returns
NumericDocValues for this field, or
null if no numeric doc values were indexed for
this field. |
abstract PointValues |
getPointValues(String field)
Returns the
PointValues used for numeric or
spatial searches for the given field, or null if there
are no point fields. |
abstract SortedDocValues |
getSortedDocValues(String field)
Returns
SortedDocValues for this field, or
null if no SortedDocValues were indexed for
this field. |
abstract SortedNumericDocValues |
getSortedNumericDocValues(String field)
Returns
SortedNumericDocValues for this field, or
null if no SortedNumericDocValues were indexed for
this field. |
abstract SortedSetDocValues |
getSortedSetDocValues(String field)
Returns
SortedSetDocValues for this field, or
null if no SortedSetDocValues were indexed for
this field. |
long |
getSumDocFreq(String field)
Returns the sum of
TermsEnum.docFreq() for all terms in this field. |
long |
getSumTotalTermFreq(String field)
Returns the sum of
TermsEnum.totalTermFreq() for all terms in this
field. |
PostingsEnum |
postings(Term term)
Returns
PostingsEnum for the specified term
with PostingsEnum.FREQS. |
PostingsEnum |
postings(Term term,
int flags)
Returns
PostingsEnum for the specified term. |
abstract Terms |
terms(String field)
Returns the
Terms index for this field, or null if it has none. |
long |
totalTermFreq(Term term)
Returns the number of documents containing the term
t. |
close, decRef, doClose, document, document, document, ensureOpen, equals, getReaderCacheHelper, getRefCount, getTermVector, getTermVectors, hasDeletions, hashCode, incRef, leaves, maxDoc, numDeletedDocs, numDocs, registerParentReader, tryIncRefprotected LeafReader()
public final LeafReaderContext getContext()
IndexReaderIndexReaderContext for this
IndexReader's sub-reader tree.
Iff this reader is composed of sub
readers, i.e. this reader being a composite reader, this method returns a
CompositeReaderContext holding the reader's direct children as well as a
view of the reader tree's atomic leaf contexts. All sub-
IndexReaderContext instances referenced from this readers top-level
context are private to this reader and are not shared with another context
tree. For example, IndexSearcher uses this API to drive searching by one
atomic leaf reader at a time. If this reader is not composed of child
readers, this method returns an LeafReaderContext.
Note: Any of the sub-CompositeReaderContext instances referenced
from this top-level context do not support CompositeReaderContext.leaves().
Only the top-level context maintains the convenience leaf-view
for performance reasons.
getContext in class IndexReaderpublic abstract IndexReader.CacheHelper getCoreCacheHelper()
IndexReader.CacheHelper that can be used to cache
based on the content of this leaf regardless of deletions. Two readers
that have the same data but different sets of deleted documents or doc
values updates may be considered equal. Consider using
IndexReader.getReaderCacheHelper() if you need deletions or dv updates to be
taken into account.
A return value of null indicates that this reader is not suited
for caching, which is typically the case for short-lived wrappers that
alter the content of the wrapped leaf reader.
public final int docFreq(Term term) throws IOException
IndexReaderterm. This method returns 0 if the term or
field does not exists. This method does not take into
account deleted documents that have not yet been merged
away.docFreq in class IndexReaderIOExceptionTermsEnum.docFreq()public final long totalTermFreq(Term term) throws IOException
t. This method returns 0 if the term or
field does not exists. This method does not take into
account deleted documents that have not yet been merged
away.totalTermFreq in class IndexReaderIOExceptionpublic final long getSumDocFreq(String field) throws IOException
IndexReaderTermsEnum.docFreq() for all terms in this field.
Note that, just like other term measures, this measure does not take deleted
documents into account.getSumDocFreq in class IndexReaderIOExceptionTerms.getSumDocFreq()public final int getDocCount(String field) throws IOException
IndexReadergetDocCount in class IndexReaderIOExceptionTerms.getDocCount()public final long getSumTotalTermFreq(String field) throws IOException
IndexReaderTermsEnum.totalTermFreq() for all terms in this
field. Note that, just like other term measures, this measure does not take
deleted documents into account.getSumTotalTermFreq in class IndexReaderIOExceptionTerms.getSumTotalTermFreq()public abstract Terms terms(String field) throws IOException
Terms index for this field, or null if it has none.IOExceptionpublic final PostingsEnum postings(Term term, int flags) throws IOException
PostingsEnum for the specified term.
This will return null if either the field or
term does not exist.
NOTE: The returned PostingsEnum may contain deleted docs.
IOExceptionTermsEnum.postings(PostingsEnum)public final PostingsEnum postings(Term term) throws IOException
PostingsEnum for the specified term
with PostingsEnum.FREQS.
Use this method if you only require documents and frequencies,
and do not need any proximity data.
This method is equivalent to
postings(term, PostingsEnum.FREQS)
NOTE: The returned PostingsEnum may contain deleted docs.
IOExceptionpostings(Term, int)public abstract NumericDocValues getNumericDocValues(String field) throws IOException
NumericDocValues for this field, or
null if no numeric doc values were indexed for
this field. The returned instance should only be
used by a single thread.IOExceptionpublic abstract BinaryDocValues getBinaryDocValues(String field) throws IOException
BinaryDocValues for this field, or
null if no binary doc values were indexed for
this field. The returned instance should only be
used by a single thread.IOExceptionpublic abstract SortedDocValues getSortedDocValues(String field) throws IOException
SortedDocValues for this field, or
null if no SortedDocValues were indexed for
this field. The returned instance should only be
used by a single thread.IOExceptionpublic abstract SortedNumericDocValues getSortedNumericDocValues(String field) throws IOException
SortedNumericDocValues for this field, or
null if no SortedNumericDocValues were indexed for
this field. The returned instance should only be
used by a single thread.IOExceptionpublic abstract SortedSetDocValues getSortedSetDocValues(String field) throws IOException
SortedSetDocValues for this field, or
null if no SortedSetDocValues were indexed for
this field. The returned instance should only be
used by a single thread.IOExceptionpublic abstract NumericDocValues getNormValues(String field) throws IOException
NumericDocValues representing norms
for this field, or null if no NumericDocValues
were indexed. The returned instance should only be
used by a single thread.IOExceptionpublic abstract FieldInfos getFieldInfos()
FieldInfos describing all fields in
this reader.
Note: Implementations should cache the FieldInfos
instance returned by this method such that subsequent
calls to this method return the same instance.public abstract Bits getLiveDocs()
Bits representing live (not
deleted) docs. A set bit indicates the doc ID has not
been deleted. If this method returns null it means
there are no deleted documents (all documents are
live).
The returned instance has been safely published for
use by multiple threads without additional
synchronization.public abstract PointValues getPointValues(String field) throws IOException
PointValues used for numeric or
spatial searches for the given field, or null if there
are no point fields.IOExceptionpublic abstract void checkIntegrity()
throws IOException
Note that this may be costly in terms of I/O, e.g. may involve computing a checksum value against large data files.
IOExceptionpublic abstract LeafMetaData getMetaData()
Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.