Skip to content

Commit 764e451

Browse files
Fix LongScriptFieldTypeTests with sorts (#78563)
Disable sort optimization with points for comparators used in scripts, as they don't provide points. This is a temporary fix, for a permanent fix these comparators should implement `getPoints` once LUCENE-10154 is available. Closes #78315
1 parent 4cb6d25 commit 764e451

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

server/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/DoubleValuesComparatorSource.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public FieldComparator<?> newComparator(String fieldname, int numHits, int sortP
7474
final double dMissingValue = (Double) missingObject(missingValue, reversed);
7575
// NOTE: it's important to pass null as a missing value in the constructor so that
7676
// the comparator doesn't check docsWithField since we replace missing values in select()
77-
return new DoubleComparator(numHits, null, null, reversed, sortPos) {
77+
DoubleComparator comparator = new DoubleComparator(numHits, null, null, reversed, sortPos) {
7878
@Override
7979
public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException {
8080
return new DoubleLeafComparator(context) {
@@ -90,6 +90,9 @@ public void setScorer(Scorable scorer) {
9090
};
9191
}
9292
};
93+
// TODO: when LUCENE-10154 is available, instead of disableSkipping this comparator should implement `getPointValue`
94+
comparator.disableSkipping();
95+
return comparator;
9396
}
9497

9598
@Override

server/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/FloatValuesComparatorSource.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public FieldComparator<?> newComparator(String fieldname, int numHits, int sortP
6767
final float fMissingValue = (Float) missingObject(missingValue, reversed);
6868
// NOTE: it's important to pass null as a missing value in the constructor so that
6969
// the comparator doesn't check docsWithField since we replace missing values in select()
70-
return new FloatComparator(numHits, null, null, reversed, sortPos) {
70+
FloatComparator comparator = new FloatComparator(numHits, null, null, reversed, sortPos) {
7171
@Override
7272
public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException {
7373
return new FloatLeafComparator(context) {
@@ -78,6 +78,9 @@ protected NumericDocValues getNumericDocValues(LeafReaderContext context, String
7878
};
7979
}
8080
};
81+
// TODO: when LUCENE-10154 is available, instead of disableSkipping this comparator should implement `getPointValue`
82+
comparator.disableSkipping();
83+
return comparator;
8184
}
8285

8386
@Override

server/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/LongValuesComparatorSource.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public FieldComparator<?> newComparator(String fieldname, int numHits, int sortP
9090
final long lMissingValue = (Long) missingObject(missingValue, reversed);
9191
// NOTE: it's important to pass null as a missing value in the constructor so that
9292
// the comparator doesn't check docsWithField since we replace missing values in select()
93-
return new LongComparator(numHits, null, null, reversed, sortPos) {
93+
LongComparator comparator = new LongComparator(numHits, null, null, reversed, sortPos) {
9494
@Override
9595
public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException {
9696
return new LongLeafComparator(context) {
@@ -101,6 +101,9 @@ protected NumericDocValues getNumericDocValues(LeafReaderContext context, String
101101
};
102102
}
103103
};
104+
// TODO: when LUCENE-10154 is available, instead of disableSkipping this comparator should implement `getPointValue`
105+
comparator.disableSkipping();
106+
return comparator;
104107
}
105108

106109
@Override

0 commit comments

Comments
 (0)