FileDocCategorySizeDatePackage
Hit.javaAPI DocApache Lucene 2.2.03715Sat Jun 16 22:20:34 BST 2007org.apache.lucene.search

Hit

public class Hit extends Object implements Serializable
Wrapper used by {@link HitIterator} to provide a lazily loaded hit from {@link Hits}.
author
Jeremy Rayner

Fields Summary
private Document
doc
private boolean
resolved
private Hits
hits
private int
hitNumber
Constructors Summary
Hit(Hits hits, int hitNumber)
Constructed from {@link HitIterator}

param
hits Hits returned from a search
param
hitNumber Hit index in Hits


                      
      
    this.hits = hits;
    this.hitNumber = hitNumber;
  
Methods Summary
private voidfetchTheHit()

    doc = hits.doc(hitNumber);
    resolved = true;
  
public java.lang.Stringget(java.lang.String name)
Returns the string value of the field with the given name if any exist in this document, or null. If multiple fields exist with this name, this method returns the first value added. If only binary fields with this name exist, returns null.

see
Document#get(String)
throws
CorruptIndexException if the index is corrupt
throws
IOException if there is a low-level IO error

    return getDocument().get(name);
  
public floatgetBoost()
Returns the boost factor for this hit on any field of the underlying document.

see
Document#getBoost()
throws
CorruptIndexException if the index is corrupt
throws
IOException if there is a low-level IO error

    return getDocument().getBoost();
  
public org.apache.lucene.document.DocumentgetDocument()
Returns document for this hit.

see
Hits#doc(int)
throws
CorruptIndexException if the index is corrupt
throws
IOException if there is a low-level IO error

    if (!resolved) fetchTheHit();
    return doc;
  
public intgetId()
Returns id for this hit.

see
Hits#id(int)

    return hits.id(hitNumber);
  
public floatgetScore()
Returns score for this hit.

see
Hits#score(int)

    return hits.score(hitNumber);
  
public java.lang.StringtoString()
Prints the parameters to be used to discover the promised result.

    StringBuffer buffer = new StringBuffer();
    buffer.append("Hit<");
    buffer.append(hits.toString());
    buffer.append(" [");
    buffer.append(hitNumber);
    buffer.append("] ");
    if (resolved) {
        buffer.append("resolved");
    } else {
        buffer.append("unresolved");
    }
    buffer.append(">");
    return buffer.toString();