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 Document Doc(int n)
{
HitDoc hitDoc = HitDoc(n);
// Update LRU cache of documents
Remove(hitDoc); // remove from list, if there
AddToFront(hitDoc); // add to front of list
if (numDocs > maxDocs)
{
// if cache is full
HitDoc oldLast = last;
Remove(last); // flush last
oldLast.doc = null; // let doc get gc'd
}
if (hitDoc.doc == null)
{
hitDoc.doc = searcher.Doc(hitDoc.id); // cache miss: read document
}
return hitDoc.doc;
}
///