jruby/docs BETA
Navigation
org.apache.lucene.index 131
C AutomatonTermsEnum
C BaseCompositeReader
C BaseTermsEnum
C BinaryDocValues
C ByteVectorValues
C CheckIndex
C CodecReader
C CompositeReader
C CompositeReaderContext
C ConcurrentMergeScheduler
C CorruptIndexException
C DirectoryReader
C DocIDMerger
C DocValues
E DocValuesSkipIndexType
C DocValuesSkipper
E DocValuesType
C DocsWithFieldSet
C EmptyDocValuesProducer
C ExitableDirectoryReader
C FieldInfo
C FieldInfos
C FieldInvertState
C Fields
C FilterBinaryDocValues
C FilterCodecReader
C FilterDirectoryReader
C FilterLeafReader
C FilterMergePolicy
C FilterNumericDocValues
C FilterSortedDocValues
C FilterSortedNumericDocValues
C FilterSortedSetDocValues
C FilteredTermsEnum
C FloatVectorValues
C FreqAndNormBuffer
C Impacts
C ImpactsEnum
I ImpactsSource
C IndexCommit
C IndexDeletionPolicy
C IndexFileNames
C IndexFormatTooNewException
C IndexFormatTooOldException
C IndexNotFoundException
E IndexOptions
C IndexReader
C IndexReaderContext
I IndexSorter
C IndexUpgrader
C IndexWriter
C IndexWriterConfig
I IndexWriterEventListener
I IndexableField
I IndexableFieldType
C KeepLastNCommitsDeletionPolicy
C KeepOnlyLastCommitDeletionPolicy
C KnnVectorValues
C LeafReader
C LeafReaderContext
C LiveIndexWriterConfig
C LogByteSizeMergePolicy
C LogDocMergePolicy
C LogMergePolicy
C MappedMultiFields
C MergePolicy
C MergeRateLimiter
C MergeScheduler
C MergeState
E MergeTrigger
C MultiBits
C MultiDocValues
C MultiFields
C MultiLeafReader
C MultiPostingsEnum
C MultiReader
C MultiTerms
C MultiTermsEnum
C NoDeletionPolicy
C NoMergePolicy
C NoMergeScheduler
C NumericDocValues
C OneMergeWrappingMergePolicy
C OrdTermState
C OrdinalMap
C ParallelCompositeReader
C ParallelLeafReader
C PersistentSnapshotDeletionPolicy
C PointValues
C PostingsEnum
C PrefixCodedTerms
I QueryTimeout
C QueryTimeoutImpl
C ReaderManager
C ReaderUtil
C SegmentCommitInfo
C SegmentInfo
C SegmentInfos
C SegmentOrder
C SegmentReadState
C SegmentReader
C SegmentWriteState
C SerialMergeScheduler
C SimpleMergedSegmentWarmer
C SingleTermsEnum
C SlowCodecReaderWrapper
C SlowImpactsEnum
C SnapshotDeletionPolicy
C SoftDeletesDirectoryReaderWrapper
C SoftDeletesRetentionMergePolicy
C SortFieldProvider
C SortedDocValues
C SortedNumericDocValues
C SortedSetDocValues
C Sorter
C SortingCodecReader
C StandardDirectoryReader
C StoredFieldVisitor
C StoredFields
C Term
C TermState
C TermStates
C TermVectors
C Terms
C TermsEnum
C TieredMergePolicy
I TwoPhaseCommit
C TwoPhaseCommitTool
C UpgradeIndexMergePolicy
E VectorEncoding
E VectorSimilarityFunction
CompositeReader — members 2+
M context() CompositeReaderContext
M to_string() String
from IndexReader
C close()
C dec_ref()
M doc_freq(term) int
M equals(obj) boolean
M get_doc_count(field) int
M get_sum_doc_freq(field) long
M get_sum_total_term_freq(field) long
M has_deletions?() boolean
M hash_code() int
C inc_ref()
M leaves() LeafReaderContext>
M max_doc() int
M num_deleted_docs() int
M num_docs() int
M reader_cache_helper() CacheHelper
M ref_count() int
C register_parent_reader(reader)
M stored_fields() StoredFields
M term_vectors() TermVectors
M total_term_freq(term) long
M try_inc_ref() boolean

org.apache.lucene.index.CompositeReader

class abstract extends IndexReader 2 members

Instances of this reader type can only be used to get stored fields from the underlying LeafReaders, but it is not possible to directly retrieve postings. To do that, get the LeafReaderContext for all sub-readers via #leaves().

IndexReader instances for indexes on disk are usually constructed with a call to one of the static DirectoryReader.open() methods, e.g. DirectoryReader#open(Directory). DirectoryReader implements the CompositeReader interface, it is not possible to directly get postings.

Concrete subclasses of IndexReader are usually constructed with a call to one of the static open() methods, e.g. DirectoryReader#open(Directory).

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.

Instance Methods

context

CompositeReaderContext context ( )
Java: getContext() · also: get_context

to_string

String to_string ( )
Java: toString()

Inherited

from IndexReader

close

close ( )
Java: close()

Closes files associated with this index. Also saves any new deletions to disk. No other methods should be called after this has been called.

Throws

IOException if there is a low-level IO error

dec_ref

dec_ref ( )
Java: decRef()

Expert: decreases the refCount of this IndexReader instance. If the refCount drops to 0, then this reader is closed. If an exception is hit, the refCount is unchanged.

Throws

IOException in case an IOException occurs in doClose()

doc_freq

int doc_freq ( Term term )
Java: docFreq(org.apache.lucene.index.Term term)

Returns the number of documents containing the term. 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.

equals

boolean equals ( Object obj )
Java: equals(Object obj)

IndexReader subclasses are not allowed to implement equals/hashCode, so methods are declared final.

get_doc_count

int get_doc_count ( String field )
Java: getDocCount(String field)

Returns the number of documents that have at least one term for this field. Note that, just like other term measures, this measure does not take deleted documents into account.

get_sum_doc_freq

long get_sum_doc_freq ( String field )
Java: getSumDocFreq(String field)

Returns the sum of TermsEnum#docFreq() for all terms in this field. Note that, just like other term measures, this measure does not take deleted documents into account.

get_sum_total_term_freq

long get_sum_total_term_freq ( String field )
Java: getSumTotalTermFreq(String field)

Returns the sum of TermsEnum#totalTermFreq for all terms in this field. Note that, just like other term measures, this measure does not take deleted documents into account.

has_deletions?

boolean has_deletions? ( )
Java: hasDeletions() · also: has_deletions

Returns true if any documents have been deleted. Implementers should consider overriding this method if #maxDoc() or #numDocs() are not constant-time operations.

hash_code

int hash_code ( )
Java: hashCode()

IndexReader subclasses are not allowed to implement equals/hashCode, so methods are declared final.

inc_ref

inc_ref ( )
Java: incRef()

Expert: increments the refCount of this IndexReader instance. RefCounts are used to determine when a reader can be closed safely, i.e. as soon as there are no more references. Be sure to always call a corresponding #decRef, in a finally clause; otherwise the reader may never be closed. Note that #close simply calls decRef(), which means that the IndexReader will not really be closed until #decRef has been called for all outstanding references.

leaves

List<LeafReaderContext> leaves ( )
Java: leaves()

Returns the reader's leaves, or itself if this reader is atomic. This is a convenience method calling this.getContext().leaves().

max_doc

int max_doc ( )
Java: maxDoc()

Returns 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.

num_deleted_docs

int num_deleted_docs ( )
Java: numDeletedDocs()

Returns the number of deleted documents.

NOTE: This operation may run in O(maxDoc).

num_docs

int num_docs ( )
Java: numDocs()

Returns the number of documents in this index.

NOTE: This operation may run in O(maxDoc). Implementations that can't return this number in constant-time should cache it.

reader_cache_helper

IndexReader.CacheHelper reader_cache_helper ( )
Java: getReaderCacheHelper() · also: get_reader_cache_helper

Optional method: Return a CacheHelper that 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 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 reader.

ref_count

int ref_count ( )
Java: getRefCount() · also: get_ref_count

Expert: returns the current refCount for this reader

register_parent_reader

register_parent_reader ( IndexReader reader )
Java: registerParentReader(org.apache.lucene.index.IndexReader reader)

Expert: This method is called by IndexReaders which wrap other readers (e.g. CompositeReader or FilterLeafReader) to register the parent at the child (this reader) on construction of the parent. When this reader is closed, it will mark all registered parents as closed, too. The references to parent readers are weak only, so they can be GCed once they are no longer in use.

stored_fields

StoredFields stored_fields ( )
Java: storedFields()

Returns a StoredFields reader for the stored fields of this index.

This call never returns null, even if no stored fields were indexed. The returned instance should only be used by a single thread.

Example:

TopDocs hits = searcher.search(query, 10);
StoredFields storedFields = reader.storedFields();
for (ScoreDoc hit : hits.scoreDocs) {
  Document doc = storedFields.document(hit.doc);
}

Throws

IOException If there is a low-level IO error

term_vectors

TermVectors term_vectors ( )
Java: termVectors()

Returns a TermVectors reader for the term vectors of this index.

This call never returns null, even if no term vectors were indexed. The returned instance should only be used by a single thread.

Example:

TopDocs hits = searcher.search(query, 10);
TermVectors termVectors = reader.termVectors();
for (ScoreDoc hit : hits.scoreDocs) {
  Fields vector = termVectors.get(hit.doc);
}

Throws

IOException If there is a low-level IO error

total_term_freq

long total_term_freq ( Term term )
Java: totalTermFreq(org.apache.lucene.index.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). Note that, like other term measures, this measure does not take deleted documents into account.

try_inc_ref

boolean try_inc_ref ( )
Java: tryIncRef()

Expert: increments the refCount of this IndexReader instance only if the IndexReader has not been closed yet and returns true iff the refCount was successfully incremented, otherwise false. If this method returns false the reader is either already closed or is currently being closed. Either way this reader instance shouldn't be used by an application unless true is returned.

RefCounts are used to determine when a reader can be closed safely, i.e. as soon as there are no more references. Be sure to always call a corresponding #decRef, in a finally clause; otherwise the reader may never be closed. Note that #close simply calls decRef(), which means that the IndexReader will not really be closed until #decRef has been called for all outstanding references.

this work for additional information regarding copyright ownership.