Skip to content

Commit

Permalink
mondodb: fix 'sum' aggregation operator
Browse files Browse the repository at this point in the history
  • Loading branch information
imedina committed Dec 12, 2024
1 parent 84d1f92 commit 26c9628
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class MongoDBQueryUtils {
public static final String OTHER = "Other";

public static final String COUNTS_SUFFIX = "Counts";
public static final String SUM_SUFFIX = "Sum";
public static final String AVG_SUFFIX = "Avg";
public static final String MIN_SUFFIX = "Min";
public static final String MAX_SUFFIX = "Max";
Expand Down Expand Up @@ -771,6 +772,10 @@ private static Facet getMongoDBFacet(String field, Accumulator accumulator, List
facet = new Facet(field + COUNTS_SUFFIX, Arrays.asList(Aggregates.group(id, Accumulators.sum(count.name(), 1))));
break;
}
case sum: {
facet = new Facet(field + SUM_SUFFIX, Arrays.asList(Aggregates.group(id, Accumulators.sum(sum.name(), id))));
break;
}
case avg: {
facet = new Facet(field + AVG_SUFFIX, Arrays.asList(Aggregates.group(field, Accumulators.avg(avg.name(), id))));
break;
Expand Down

0 comments on commit 26c9628

Please sign in to comment.