<spr...@gmx.eu> <spr...@gmx.eu> wrote:

Looking into TopDocCollector code, I have some questions:

* How can a hit have a score of <=0?

I'm not sure...

* What happens if the first hit has the highest score of all hits? It seems
that topDocs whould then contain only this doc!?

That works fine, because hq.size() is still less than numHits. So nomatter what, the first numHits hits will be added to the queue.

public void collect(int doc, float score) {
57     if (score > 0.0f) {
58       totalHits++;
59       if (hq.size() < numHits || score >= minScore) {
60         hq.insert(new ScoreDoc(doc, score));
61         minScore = ((ScoreDoc)hq.top()).score; // maintain minScore
62 }
63     }
64   }

Mike

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to