Save This Page
Home » lucene-2.3.2-src » org.apache » lucene » search » [javadoc | source]
org.apache.lucene.search
public final class: Hits [javadoc | source]
java.lang.Object
   org.apache.lucene.search.Hits
A 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, ConcurrentModificationException is thrown when accessing hit n ≥ current_#length() (but n < #length() _at_start).
Field Summary
 boolean debugCheckedForDeletions     
Constructor:
 Hits(Searcher s,
    Query q,
    Filter f) throws IOException 
 Hits(Searcher s,
    Query q,
    Filter f,
    Sort o) throws IOException 
Method from org.apache.lucene.search.Hits Summary:
doc,   id,   iterator,   length,   score
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.lucene.search.Hits Detail:
 public final Document doc(int n) throws IOException, CorruptIndexException 
    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.

 public final int id(int n) throws IOException 
    Returns 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.
 public Iterator iterator() 
    Returns a HitIterator to navigate the Hits. Each item returned from Iterator#next() is a Hit .

    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 .

 public final int length() 
    Returns the total number of hits available in this set.
 public final float score(int n) throws IOException 
    Returns the score for the nth document in this set.