fix the logic to require the next float when checking the global minimum score

This commit is contained in:
jimczi 2019-10-21 14:18:10 +02:00
parent a35996fcbb
commit 66a8ad04e7
2 changed files with 7 additions and 7 deletions

View File

@ -243,7 +243,7 @@ public abstract class TopScoreDocCollector extends TopDocsCollector<ScoreDoc> {
* and a shared {@link MaxScoreAccumulator} to propagate the minimum score accross segments * and a shared {@link MaxScoreAccumulator} to propagate the minimum score accross segments
*/ */
public static CollectorManager<TopScoreDocCollector, TopDocs> createSharedManager(int numHits, FieldDoc after, public static CollectorManager<TopScoreDocCollector, TopDocs> createSharedManager(int numHits, FieldDoc after,
int totalHitsThreshold, int maxDocs) { int totalHitsThreshold) {
return new CollectorManager<>() { return new CollectorManager<>() {
private final HitsThresholdChecker hitsThresholdChecker = HitsThresholdChecker.createShared(totalHitsThreshold); private final HitsThresholdChecker hitsThresholdChecker = HitsThresholdChecker.createShared(totalHitsThreshold);
@ -305,9 +305,9 @@ public abstract class TopScoreDocCollector extends TopDocsCollector<ScoreDoc> {
DocAndScore maxMinScore = minScoreAcc.get(); DocAndScore maxMinScore = minScoreAcc.get();
if (maxMinScore != null) { if (maxMinScore != null) {
// since we tie-break on doc id and collect in doc id order we can require // since we tie-break on doc id and collect in doc id order we can require
// the next float if the global minimum score is set on a document that is // the next float if the global minimum score is set on a document id that is
// greater than the ids in the current leaf // smaller than the ids in the current leaf
float score = maxMinScore.docID > docBase ? Math.nextUp(maxMinScore.score) : maxMinScore.score; float score = docBase > maxMinScore.docID ? Math.nextUp(maxMinScore.score) : maxMinScore.score;
if (score > minCompetitiveScore) { if (score > minCompetitiveScore) {
assert hitsThresholdChecker.isThresholdReached(); assert hitsThresholdChecker.isThresholdReached();
scorer.setMinCompetitiveScore(score); scorer.setMinCompetitiveScore(score);

View File

@ -129,7 +129,7 @@ public class TestTopDocsCollector extends LuceneTestCase {
IndexSearcher searcher = new IndexSearcher(indexReader, service); IndexSearcher searcher = new IndexSearcher(indexReader, service);
CollectorManager collectorManager = TopScoreDocCollector.createSharedManager(numResults, CollectorManager collectorManager = TopScoreDocCollector.createSharedManager(numResults,
null, threshold, indexReader.maxDoc()); null, threshold);
return (TopDocs) searcher.search(q, collectorManager); return (TopDocs) searcher.search(q, collectorManager);
} finally { } finally {
@ -417,7 +417,7 @@ public class TestTopDocsCollector extends LuceneTestCase {
w.close(); w.close();
CollectorManager<TopScoreDocCollector, TopDocs> manager = CollectorManager<TopScoreDocCollector, TopDocs> manager =
TopScoreDocCollector.createSharedManager(2, null, 0, reader.maxDoc()); TopScoreDocCollector.createSharedManager(2, null, 0);
TopScoreDocCollector collector = manager.newCollector(); TopScoreDocCollector collector = manager.newCollector();
TopScoreDocCollector collector2 = manager.newCollector(); TopScoreDocCollector collector2 = manager.newCollector();
assertTrue(collector.minScoreAcc == collector2.minScoreAcc); assertTrue(collector.minScoreAcc == collector2.minScoreAcc);