org.apache.lucene.search

Class TopDocCollector

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
voidcollect(int doc, float score)
intgetTotalHits()
The total number of documents that matched this query.
TopDocstopDocs()
The top-scoring hits.

Constructor Detail

TopDocCollector

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

Parameters: numHits the maximum number of hits to collect

Method Detail

collect

public void collect(int doc, float score)

getTotalHits

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

topDocs

public TopDocs topDocs()
The top-scoring hits.
Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.