|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.search.Collector org.apache.lucene.search.TopDocsCollector<T>
public abstract class TopDocsCollector<T extends ScoreDoc>
A base class for all collectors that return a TopDocs
output. This
collector allows easy extension by providing a single constructor which
accepts a PriorityQueue
as well as protected members for that
priority queue and a counter of the number of total hits.
Extending classes can override any of the methods to provide their own
implementation, as well as avoid the use of the priority queue entirely by
passing null to TopDocsCollector(PriorityQueue)
. In that case
however, you might want to consider overriding all methods, in order to avoid
a NullPointerException.
Field Summary | |
---|---|
protected static TopDocs |
EMPTY_TOPDOCS
|
protected PriorityQueue<T> |
pq
The priority queue which holds the top documents. |
protected int |
totalHits
The total number of documents that the collector encountered. |
Constructor Summary | |
---|---|
protected |
TopDocsCollector(PriorityQueue<T> pq)
|
Method Summary | |
---|---|
int |
getTotalHits()
The total number of documents that matched this query. |
protected TopDocs |
newTopDocs(ScoreDoc[] results,
int start)
Returns a TopDocs instance containing the given results. |
protected void |
populateResults(ScoreDoc[] results,
int howMany)
Populates the results array with the ScoreDoc instances. |
TopDocs |
topDocs()
Returns the top docs that were collected by this collector. |
TopDocs |
topDocs(int start)
Returns the documents in the rage [start .. |
TopDocs |
topDocs(int start,
int howMany)
Returns the documents in the rage [start .. |
Methods inherited from class org.apache.lucene.search.Collector |
---|
acceptsDocsOutOfOrder, collect, setNextReader, setScorer |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final TopDocs EMPTY_TOPDOCS
protected PriorityQueue<T extends ScoreDoc> pq
protected int totalHits
Constructor Detail |
---|
protected TopDocsCollector(PriorityQueue<T> pq)
Method Detail |
---|
protected void populateResults(ScoreDoc[] results, int howMany)
protected TopDocs newTopDocs(ScoreDoc[] results, int start)
TopDocs
instance containing the given results. If
results
is null it means there are no results to return,
either because there were 0 calls to collect() or because the arguments to
topDocs were invalid.
public int getTotalHits()
public TopDocs topDocs()
public TopDocs topDocs(int start)
start
, you should call topDocs()
and work
with the returned TopDocs
object, which will contain all the
results this search execution collected.
public TopDocs topDocs(int start, int howMany)
topDocs()
and work with the
returned TopDocs
object, which will contain all the results this
search execution collected.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |