public abstract class AtomicReader extends IndexReader
AtomicReader
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.ReaderClosedListener
Modifier | Constructor and Description |
---|---|
protected |
AtomicReader()
Sole constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
docFreq(Term term)
Returns the number of documents containing the
term . |
abstract DocValues |
docValues(String field)
Returns
DocValues for this field. |
abstract Fields |
fields()
Returns
Fields for this reader. |
AtomicReaderContext |
getContext()
Expert: Returns the root
IndexReaderContext for this
IndexReader 's sub-reader tree. |
abstract FieldInfos |
getFieldInfos()
Get the
FieldInfos describing all fields in
this reader. |
abstract Bits |
getLiveDocs()
Returns the
Bits representing live (not
deleted) docs. |
boolean |
hasNorms(String field)
Deprecated.
(4.0) use
getFieldInfos() and check FieldInfo.hasNorms()
for the field instead. |
abstract DocValues |
normValues(String field)
Returns
DocValues for this field's normalization values. |
DocsEnum |
termDocsEnum(Term term)
Returns
DocsEnum for the specified term. |
DocsAndPositionsEnum |
termPositionsEnum(Term term)
Returns
DocsAndPositionsEnum for the specified
term. |
Terms |
terms(String field)
This may return null if the field does not exist.
|
long |
totalTermFreq(Term term)
Returns the number of documents containing the term
t . |
addReaderClosedListener, close, decRef, doClose, document, document, document, ensureOpen, equals, getCombinedCoreAndDeletesKey, getCoreCacheKey, getRefCount, getTermVector, getTermVectors, hasDeletions, hashCode, incRef, leaves, maxDoc, numDeletedDocs, numDocs, open, open, open, open, open, registerParentReader, removeReaderClosedListener, tryIncRef
protected AtomicReader()
public final AtomicReaderContext getContext()
IndexReader
IndexReaderContext
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 AtomicReaderContext
.
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 IndexReader
@Deprecated public final boolean hasNorms(String field) throws IOException
IOException
public abstract Fields fields() throws IOException
Fields
for this reader.
This method may return null if the reader has no
postings.IOException
public final int docFreq(Term term) throws IOException
IndexReader
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.docFreq
in class IndexReader
IOException
TermsEnum.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 IndexReader
IOException
TermsEnum.totalTermFreq()
public final Terms terms(String field) throws IOException
IOException
public final DocsEnum termDocsEnum(Term term) throws IOException
DocsEnum
for the specified term.
This will return null if either the field or
term does not exist.IOException
TermsEnum.docs(Bits, DocsEnum)
public final DocsAndPositionsEnum termPositionsEnum(Term term) throws IOException
DocsAndPositionsEnum
for the specified
term. This will return null if the
field or term does not exist or positions weren't indexed.IOException
TermsEnum.docsAndPositions(Bits, DocsAndPositionsEnum)
public abstract DocValues docValues(String field) throws IOException
DocValues
for this field.
This method may return null if the reader has no per-document
values stored.IOException
public abstract DocValues normValues(String field) throws IOException
DocValues
for this field's normalization values.
This method may return null if the field has no norms.IOException
public abstract FieldInfos getFieldInfos()
FieldInfos
describing all fields in
this reader.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.Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.