diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/GlobalOrdCardinalityAggregator.java b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/GlobalOrdCardinalityAggregator.java index a8afc370670e8..ee412666a21fa 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/GlobalOrdCardinalityAggregator.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/GlobalOrdCardinalityAggregator.java @@ -211,7 +211,7 @@ public LeafBucketCollector getLeafCollector(AggregationExecutionContext aggCtx, if (maxOrd <= MAX_FIELD_CARDINALITY_FOR_DYNAMIC_PRUNING || numNonVisitedOrds <= MAX_TERMS_FOR_DYNAMIC_PRUNING) { dynamicPruningAttempts++; return new LeafBucketCollector() { - final SortedSetDocValues docValues = valuesSource.globalOrdinalsValues(aggCtx.getLeafReaderContext()); + final SortedSetDocValues docValues = values; final BitArray bits; final CompetitiveIterator competitiveIterator; @@ -268,7 +268,7 @@ public CompetitiveIterator competitiveIterator() { bruteForce++; return new LeafBucketCollector() { - final SortedSetDocValues docValues = valuesSource.globalOrdinalsValues(aggCtx.getLeafReaderContext()); + final SortedSetDocValues docValues = values; @Override public void collect(int doc, long bucketOrd) throws IOException {