mirror of https://github.com/apache/lucene.git
fix the logic to require the next float when checking the global minimum score
This commit is contained in:
parent
a35996fcbb
commit
66a8ad04e7
|
@ -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);
|
||||||
|
@ -328,7 +328,7 @@ public abstract class TopScoreDocCollector extends TopDocsCollector<ScoreDoc> {
|
||||||
scorer.setMinCompetitiveScore(localMinScore);
|
scorer.setMinCompetitiveScore(localMinScore);
|
||||||
totalHitsRelation = TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO;
|
totalHitsRelation = TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO;
|
||||||
minCompetitiveScore = localMinScore;
|
minCompetitiveScore = localMinScore;
|
||||||
if (minScoreAcc!= null) {
|
if (minScoreAcc != null) {
|
||||||
// we don't use the next float but we register the document
|
// we don't use the next float but we register the document
|
||||||
// id so that other leaves can require it if they are after
|
// id so that other leaves can require it if they are after
|
||||||
// the current maximum
|
// the current maximum
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue