|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IndexReader
Provides access to an inverted index.
An Index
contains global read-only metadata. To get actual data
from an index, you need to get an index reader via a call to Index.getReader()
. Once
you have an index reader, you can ask for the documents matching a term.
Alternatively, you can perform a read-once scan of the index calling nextIterator()
,
which will return in order the index iterators of all terms of the underlying index.
More generally, nextIterator()
returns an iterator positioned at the start of the inverted
list of the term after the current one. When called just after the reader creation, it returns an
index iterator for the first term.
Warning: An index reader is exactly what it looks like—a reader. It cannot be used by many threads at the same time, and all its access methods are exclusive: if you obtain a document iterator, the previous one is no longer valid. However, you can generate many readers, and use them concurrently.
Warning: Invoking the DocumentIterator.dispose()
method
on iterators returned by an instance of this class will invoke Closeable.close()
on the instance, thus
making the instance no longer accessible. This behaviour is necessary to handle cases in which a
reader is created on-the-fly just to create an iterator.
Method Summary | |
---|---|
IndexIterator |
documents(CharSequence term)
Returns an index iterator over the documents containing a term; the term is given explicitly. |
IndexIterator |
documents(int termNumber)
Returns a document iterator over the documents containing a term. |
IndexIterator |
nextIterator()
Returns an IndexIterator on the term after the current one (optional operation). |
Methods inherited from interface java.io.Closeable |
---|
close |
Method Detail |
---|
IndexIterator documents(int termNumber) throws IOException
Note that the index iterator returned by this method will
return null
on a call to term()
.
Note that it is always possible to call this method with argument 0, even if the underlying index does not provide random access.
termNumber
- the number of a term.
UnsupportedOperationException
- if this index reader is not accessible by term
number.
IOException
IndexIterator documents(CharSequence term) throws IOException
Unless the term processor of
the associated index is null
, words coming from a query will
have to be processed before being used with this method.
Note that the index iterator returned by this method will
return term
on a call to term()
.
term
- a term (the term will be downcased if the index is case insensitive).
UnsupportedOperationException
- if the term map is not available for the underlying index.
IOException
IndexIterator nextIterator() throws IOException
IndexIterator
on the term after the current one (optional operation).
Note that after creation there is no current term. Thus, the first call to this
method will return an IndexIterator
on the first term. As a consequence, repeated
calls to this method provide a way to scan sequentially an index.
null
if there are no more terms
after the current one.
IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |