org.apache.lucene.search

Class TopDocCollector

Known Direct Subclasses:
TopFieldDocCollector

public class TopDocCollector
extends HitCollector

A HitCollector implementation that collects the top-scoring documents, returning them as a TopDocs. This is used by IndexSearcher to implement TopDocs-based search.

This may be extended, overriding the collect method to, e.g., conditionally invoke super() in order to filter which documents are collected.

Constructor Summary

TopDocCollector(int numHits)
Construct to collect a given number of hits.

Method Summary

void
collect(int doc, float score)
Called once for every non-zero scoring document, with the document number and its score.
int
getTotalHits()
The total number of documents that matched this query.
TopDocs
topDocs()
The top-scoring hits.

Methods inherited from class org.apache.lucene.search.HitCollector

collect

Constructor Details

TopDocCollector

public TopDocCollector(int numHits)
Construct to collect a given number of hits.
Parameters:
numHits - the maximum number of hits to collect

Method Details

collect

public void collect(int doc,
                    float score)
Overrides:
collect in interface HitCollector

getTotalHits

public int getTotalHits()
The total number of documents that matched this query.

topDocs

public TopDocs topDocs()
The top-scoring hits.

Copyright © 2000-2006 Apache Software Foundation. All Rights Reserved.