org.apache.lucene.search

Class TopFieldDocCollector


public class TopFieldDocCollector
extends TopDocCollector

A HitCollector implementation that collects the top-sorting documents, returning them as a TopFieldDocs. This is used by IndexSearcher to implement TopFieldDocs-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

TopFieldDocCollector(IndexReader reader, Sort sort, 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.
TopDocs
topDocs()

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

collect, getTotalHits, topDocs

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

collect

Constructor Details

TopFieldDocCollector

public TopFieldDocCollector(IndexReader reader,
                            Sort sort,
                            int numHits)
            throws IOException
Construct to collect a given number of hits.
Parameters:
reader - the index to be searched
sort - the sort criteria
numHits - the maximum number of hits to collect

Method Details

collect

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

topDocs

public TopDocs topDocs()
Overrides:
topDocs in interface TopDocCollector

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