diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index abdda667cb3e..97712c88e12b 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -61,6 +61,8 @@ Bug Fixes * GITHUB#14523, GITHUB#14530: Correct TermOrdValComparator competitive iterator so that it forces sparse field iteration to be at least scoring window baseline when doing intoBitSet. (Ben Trent, Adrien Grand) +* GITHUB#14445: Provide better impacts for fields indexed with IndexOptions.DOCS GITHUB#14511 (Aniketh Jain) + * GITHUB#14543: Fixed lead cost computations for bulk scorers of conjunctive queries that mix MUST and FILTER clauses, and disjunctive queries that configure a minimum number of matching SHOULD clauses. diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene101/Lucene101PostingsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene101/Lucene101PostingsReader.java index 052e281ca567..9141ad5133dd 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene101/Lucene101PostingsReader.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene101/Lucene101PostingsReader.java @@ -73,6 +73,10 @@ public final class Lucene101PostingsReader extends PostingsReaderBase { private static final List DUMMY_IMPACTS = Collections.singletonList(new Impact(Integer.MAX_VALUE, 1L)); + // We stopped storing a placeholder impact with freq=1 for fields with DOCS after 9.12.0 + private static final List DUMMY_IMPACTS_NO_FREQS = + Collections.singletonList(new Impact(1, 1L)); + private final IndexInput docIn; private final IndexInput posIn; private final IndexInput payIn; @@ -1328,13 +1332,14 @@ public int getDocIdUpTo(int level) { @Override public List getImpacts(int level) { - if (indexHasFreq) { - if (level == 0 && level0LastDocID != NO_MORE_DOCS) { - return readImpacts(level0SerializedImpacts, level0Impacts); - } - if (level == 1) { - return readImpacts(level1SerializedImpacts, level1Impacts); - } + if (indexHasFreq == false) { + return DUMMY_IMPACTS_NO_FREQS; + } + if (level == 0 && level0LastDocID != NO_MORE_DOCS) { + return readImpacts(level0SerializedImpacts, level0Impacts); + } + if (level == 1) { + return readImpacts(level1SerializedImpacts, level1Impacts); } return DUMMY_IMPACTS; }