Class Hits
- java.lang.Object
-
- org.apache.lucene.search.Hits
-
public final class Hits extends java.lang.ObjectA ranked list of documents, used to hold search results.Caution: Iterate only over the hits needed. Iterating over all hits is generally not desirable and may be the source of performance issues. If you need to iterate over many or all hits, consider using the search method that takes a
HitCollector.Note: Deleting matching documents concurrently with traversing the hits, might, when deleting hits that were not yet retrieved, decrease
length(). In such case,ConcurrentModificationExceptionis thrown when accessing hitn≥ current_length()(butn<length()_at_start).
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description Documentdoc(int n)Returns the stored fields of the nth document in this set.intid(int n)Returns the id for the nth document in this set.java.util.Iteratoriterator()Returns aHitIteratorto navigate the Hits.intlength()Returns the total number of hits available in this set.floatscore(int n)Returns the score for the nth document in this set.
-
-
-
Method Detail
-
length
public final int length()
Returns the total number of hits available in this set.
-
doc
public final Document doc(int n) throws CorruptIndexException, java.io.IOException
Returns the stored fields of the nth document in this set.Documents are cached, so that repeated requests for the same element may return the same Document object.
- Throws:
CorruptIndexException- if the index is corruptjava.io.IOException- if there is a low-level IO error
-
score
public final float score(int n) throws java.io.IOExceptionReturns the score for the nth document in this set.- Throws:
java.io.IOException
-
id
public final int id(int n) throws java.io.IOExceptionReturns the id for the nth document in this set. Note that ids may change when the index changes, so you cannot rely on the id to be stable.- Throws:
java.io.IOException
-
iterator
public java.util.Iterator iterator()
Returns aHitIteratorto navigate the Hits. Each item returned fromIterator.next()is aHit.Caution: Iterate only over the hits needed. Iterating over all hits is generally not desirable and may be the source of performance issues. If you need to iterate over many or all hits, consider using a search method that takes a
HitCollector.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG