Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docCountError must be 0 for shard level reduce #9246

Merged
merged 1 commit into from
Aug 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,11 @@ private BucketOrder getReduceOrder(List<InternalAggregation> aggregations) {
return thisReduceOrder != null ? thisReduceOrder : order;
}

private long getDocCountError(InternalTerms<?, ?> terms) {
private long getDocCountError(InternalTerms<?, ?> terms, ReduceContext reduceContext) {
int size = terms.getBuckets().size();
if (size == 0 || size < terms.getShardSize() || isKeyOrder(terms.order)) {
// doc_count_error is always computed at the coordinator based on the buckets returned by the shards. This should be 0 during the
// shard level reduce as no buckets are being pruned at this stage.
if (reduceContext.isSliceLevel() || size == 0 || size < terms.getShardSize() || isKeyOrder(terms.order)) {
jed326 marked this conversation as resolved.
Show resolved Hide resolved
return 0;
} else if (InternalOrder.isCountDesc(terms.order)) {
if (terms.getDocCountError() > 0) {
Expand Down Expand Up @@ -412,7 +414,7 @@ public InternalAggregation reduce(List<InternalAggregation> aggregations, Reduce
);
}
otherDocCount += terms.getSumOfOtherDocCounts();
final long thisAggDocCountError = getDocCountError(terms);
final long thisAggDocCountError = getDocCountError(terms, reduceContext);
if (sumDocCountError != -1) {
if (thisAggDocCountError == -1) {
sumDocCountError = -1;
Expand Down