Skip to content

Apache Lucene open-source search software

LUCENE-10633: Fix handling of missing values in reverse sorts.

Adrien Grand7c9d3cd6ff6c
diff --git a/lucene/core/src/java/org/apache/lucene/search/comparators/TermOrdValComparator.java b/lucene/core/src/java/org/apache/lucene/search/comparators/TermOrdValComparator.java
index 36e64f6df89..cff3f846162 100644
--- a/lucene/core/src/java/org/apache/lucene/search/comparators/TermOrdValComparator.java
+++ b/lucene/core/src/java/org/apache/lucene/search/comparators/TermOrdValComparator.java
@@ -403,7 +403,7 @@ public class TermOrdValComparator extends FieldComparator<BytesRef> {
minOrd = -1;
}
- if (bottomOrd == Integer.MAX_VALUE) {
+ if (bottomOrd == missingOrd) {
// The queue still contains missing values.
if (singleSort) {
// If there is no tie breaker, we can start ignoring missing values from now on.
@@ -421,7 +421,7 @@ public class TermOrdValComparator extends FieldComparator<BytesRef> {
} else {
- if (bottomOrd == -1) {
+ if (bottomOrd == missingOrd) {
// The queue still contains missing values.
if (singleSort) {
// If there is no tie breaker, we can start ignoring missing values from now on.