Class BaseCompositeReader<R extends IndexReader>
- java.lang.Object
-
- org.apache.lucene.index.IndexReader
-
- org.apache.lucene.index.CompositeReader
-
- org.apache.lucene.index.BaseCompositeReader<R>
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
- Direct Known Subclasses:
DirectoryReader,MultiReader,ParallelCompositeReader
public abstract class BaseCompositeReader<R extends IndexReader> extends CompositeReader
Base class for implementingCompositeReaders 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
MultiReaderto build a composite reader on a set of sub-readers (like severalDirectoryReaders).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:
IndexReaderinstances 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 theIndexReaderinstance; use your own (non-Lucene) objects instead.- See Also:
MultiReader
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.lucene.index.IndexReader
IndexReader.ReaderClosedListener
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intdocFreq(Term term)Returns the number of documents containing theterm.voiddocument(int docID, StoredFieldVisitor visitor)Expert: visits the fields of a stored document, for custom processing/loading of each field.intgetDocCount(java.lang.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.longgetSumDocFreq(java.lang.String field)Returns the sum ofTermsEnum.docFreq()for all terms in this field, or -1 if this measure isn't stored by the codec.longgetSumTotalTermFreq(java.lang.String field)Returns the sum ofTermsEnum.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).FieldsgetTermVectors(int docID)Retrieve term vectors for this document, or null if term vectors were not indexed.intmaxDoc()Returns one greater than the largest possible document number.intnumDocs()Returns the number of documents in this index.longtotalTermFreq(Term term)Returns the total number of occurrences oftermacross all documents (the sum of the freq() for each doc that has this term).-
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, open, open, open, open, open, registerParentReader, removeReaderClosedListener, tryIncRef
-
-
-
-
Method Detail
-
getTermVectors
public final Fields getTermVectors(int docID) throws java.io.IOException
Description copied from class:IndexReaderRetrieve term vectors for this document, or null if term vectors were not indexed. The returned Fields instance acts like a single-document inverted index (the docID will be 0).- Specified by:
getTermVectorsin classIndexReader- Throws:
java.io.IOException
-
numDocs
public final int numDocs()
Description copied from class:IndexReaderReturns the number of documents in this index.- Specified by:
numDocsin classIndexReader
-
maxDoc
public final int maxDoc()
Description copied from class:IndexReaderReturns one greater than the largest possible document number. This may be used to, e.g., determine how big to allocate an array which will have an element for every document number in an index.- Specified by:
maxDocin classIndexReader
-
document
public final void document(int docID, StoredFieldVisitor visitor) throws java.io.IOExceptionDescription copied from class:IndexReaderExpert: visits the fields of a stored document, for custom processing/loading of each field. If you simply want to load all fields, useIndexReader.document(int). If you want to load a subset, useDocumentStoredFieldVisitor.- Specified by:
documentin classIndexReader- Throws:
java.io.IOException
-
docFreq
public final int docFreq(Term term) throws java.io.IOException
Description copied from class:IndexReaderReturns the number of documents containing theterm. 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.- Specified by:
docFreqin classIndexReader- Throws:
java.io.IOException- See Also:
TermsEnum.docFreq()
-
totalTermFreq
public final long totalTermFreq(Term term) throws java.io.IOException
Description copied from class:IndexReaderReturns the total number of occurrences oftermacross 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.- Specified by:
totalTermFreqin classIndexReader- Throws:
java.io.IOException
-
getSumDocFreq
public final long getSumDocFreq(java.lang.String field) throws java.io.IOExceptionDescription copied from class:IndexReaderReturns the sum ofTermsEnum.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.- Specified by:
getSumDocFreqin classIndexReader- Throws:
java.io.IOException- See Also:
Terms.getSumDocFreq()
-
getDocCount
public final int getDocCount(java.lang.String field) throws java.io.IOExceptionDescription copied from class:IndexReaderReturns the number of documents that have at least one term for 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.- Specified by:
getDocCountin classIndexReader- Throws:
java.io.IOException- See Also:
Terms.getDocCount()
-
getSumTotalTermFreq
public final long getSumTotalTermFreq(java.lang.String field) throws java.io.IOExceptionDescription copied from class:IndexReaderReturns the sum ofTermsEnum.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.- Specified by:
getSumTotalTermFreqin classIndexReader- Throws:
java.io.IOException- See Also:
Terms.getSumTotalTermFreq()
-
-