public abstract class BaseCompositeReader<R extends IndexReader> extends CompositeReader
CompositeReaders based on an array
of sub-readers. The implementing class has to add code for
correctly refcounting and closing the sub-readers.
User code will most likely use MultiReader to build a
composite reader on a set of sub-readers (like several
DirectoryReaders).
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.
MultiReaderIndexReader.ReaderClosedListener| Modifier | Constructor and Description |
|---|---|
protected |
BaseCompositeReader(R[] subReaders)
Constructs a
BaseCompositeReader on the given subReaders. |
| Modifier and Type | Method and Description |
|---|---|
int |
docFreq(Term term)
Returns the number of documents containing the
term. |
void |
document(int docID,
StoredFieldVisitor visitor)
Expert: visits the fields of a stored document, for
custom processing/loading of each field.
|
int |
getDocCount(String field)
Returns the number of documents that have at least one term for this field,
or -1 if this measure isn't stored by the codec.
|
protected List<? extends R> |
getSequentialSubReaders()
Expert: returns the sequential sub readers that this
reader is logically composed of.
|
long |
getSumDocFreq(String field)
Returns the sum of
TermsEnum.docFreq() for all terms in this field,
or -1 if this measure isn't stored by the codec. |
long |
getSumTotalTermFreq(String field)
Returns the sum of
TermsEnum.totalTermFreq() for all terms in this
field, or -1 if this measure isn't stored by the codec (or if this fields
omits term freq and positions). |
Fields |
getTermVectors(int docID)
Retrieve term vectors for this document, or null if
term vectors were not indexed.
|
int |
maxDoc()
Returns one greater than the largest possible document number.
|
int |
numDocs()
Returns the number of documents in this index.
|
protected int |
readerBase(int readerIndex)
Helper method for subclasses to get the docBase of the given sub-reader index.
|
protected int |
readerIndex(int docID)
Helper method for subclasses to get the corresponding reader for a doc ID
|
long |
totalTermFreq(Term term)
Returns the total number of occurrences of
term across all
documents (the sum of the freq() for each doc that has this term). |
getContext, toStringaddReaderClosedListener, close, decRef, doClose, document, document, ensureOpen, equals, getCombinedCoreAndDeletesKey, getCoreCacheKey, getRefCount, getTermVector, hasDeletions, hashCode, incRef, leaves, numDeletedDocs, registerParentReader, removeReaderClosedListener, tryIncRefprotected BaseCompositeReader(R[] subReaders) throws IOException
BaseCompositeReader on the given subReaders.subReaders - the wrapped sub-readers. This array is returned by
getSequentialSubReaders() and used to resolve the correct
subreader for docID-based methods. Please note: This array is not
cloned and not protected for modification, the subclass is responsible
to do this.IOExceptionpublic final Fields getTermVectors(int docID) throws IOException
IndexReadergetTermVectors in class IndexReaderIOExceptionpublic final int numDocs()
IndexReadernumDocs in class IndexReaderpublic final int maxDoc()
IndexReadermaxDoc in class IndexReaderpublic final void document(int docID,
StoredFieldVisitor visitor)
throws IOException
IndexReaderIndexReader.document(int). If you want to load a subset, use
DocumentStoredFieldVisitor.document in class IndexReaderIOExceptionpublic 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
IndexReaderterm across all
documents (the sum of the freq() for each doc that has this term). This
will be -1 if the codec doesn't support this measure. Note that, like other
term measures, this measure does not take deleted documents into account.totalTermFreq in class IndexReaderIOExceptionpublic final long getSumDocFreq(String field) throws IOException
IndexReaderTermsEnum.docFreq() for all terms in this field,
or -1 if this measure isn't stored by the codec. 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, or -1 if this measure isn't stored by the codec (or if this fields
omits term freq and positions). Note that, just like other term measures,
this measure does not take deleted documents into account.getSumTotalTermFreq in class IndexReaderIOExceptionTerms.getSumTotalTermFreq()protected final int readerIndex(int docID)
protected final int readerBase(int readerIndex)
protected final List<? extends R> getSequentialSubReaders()
CompositeReadernull.
NOTE: In contrast to previous Lucene versions this method
is no longer public, code that wants to get all LeafReaders
this composite is composed of should use IndexReader.leaves().
getSequentialSubReaders in class CompositeReaderIndexReader.leaves()Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.