Skip to content

Commit d0a2218

Browse files
committed
only run accelerator on dense fields
1 parent e32f535 commit d0a2218

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,11 @@ public FieldComparator<?> newComparator(String fieldname, int numHits, Pruning e
109109
return new XLongComparator(numHits, fieldname, null, reversed, enableSkipping) {
110110
@Override
111111
public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException {
112+
final int maxDoc = context.reader().maxDoc();
112113
return new LongLeafComparator(context) {
113114
@Override
114115
protected NumericDocValues getNumericDocValues(LeafReaderContext context, String field) throws IOException {
115-
return wrap(getLongValues(context, lMissingValue), context.reader().maxDoc());
116+
return wrap(getLongValues(context, lMissingValue), maxDoc);
116117
}
117118

118119
@Override
@@ -131,7 +132,7 @@ protected XNumericComparator<Long>.CompetitiveDISIBuilder buildCompetitiveDISIBu
131132
}
132133
DocValuesSkipper skipper = context.reader().getDocValuesSkipper(field);
133134
DocValuesSkipper primaryFieldSkipper = context.reader().getDocValuesSkipper(sortFields[0].getField());
134-
if (primaryFieldSkipper == null) {
135+
if (primaryFieldSkipper == null || skipper.docCount() != maxDoc || primaryFieldSkipper.docCount() != maxDoc) {
135136
return super.buildCompetitiveDISIBuilder(context);
136137
}
137138
return new CompetitiveDISIBuilder(this) {

0 commit comments

Comments
 (0)