Oops. Fixed a bug I introduced in my last change. Thanks to

Cristoph for catching this!  I overgeneralized.  Sorted results are
not always the highest scoring.


git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150535 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Doug Cutting 2004-09-28 16:54:44 +00:00
parent 5a3cfc5372
commit 1b8843fa04
1 changed files with 3 additions and 7 deletions

View File

@ -123,15 +123,11 @@ public class IndexSearcher extends Searcher {
new FieldSortedHitQueue(reader, sort.fields, nDocs);
final int[] totalHits = new int[1];
scorer.score(new HitCollector() {
private float minScore = 0.0f;
public final void collect(int doc, float score) {
if (score > 0.0f && // ignore zeroed buckets
(bits==null || bits.get(doc))) { // skip docs not in bits
if (score > 0.0f && // ignore zeroed buckets
(bits==null || bits.get(doc))) { // skip docs not in bits
totalHits[0]++;
if (hq.size() < nDocs || score >= minScore) {
hq.insert(new FieldDoc(doc, score));
minScore = ((FieldDoc)hq.top()).score; // maintain minScore
}
hq.insert(new FieldDoc(doc, score));
}
}
});