diff --git a/commons-datastore/commons-datastore-mongodb/src/main/java/org/opencb/commons/datastore/mongodb/MongoDBQueryUtils.java b/commons-datastore/commons-datastore-mongodb/src/main/java/org/opencb/commons/datastore/mongodb/MongoDBQueryUtils.java index 47065bd9..fbb529e0 100644 --- a/commons-datastore/commons-datastore-mongodb/src/main/java/org/opencb/commons/datastore/mongodb/MongoDBQueryUtils.java +++ b/commons-datastore/commons-datastore-mongodb/src/main/java/org/opencb/commons/datastore/mongodb/MongoDBQueryUtils.java @@ -782,7 +782,13 @@ private static Facet getMongoDBFacet(String field, Accumulator accumulator, List switch (accumulator) { case count: { // facet = new Facet(field + COUNTS_SUFFIX, Arrays.asList(Aggregates.group(id, Accumulators.sum(count.name(), 1)))); - facet = new Facet(field + COUNTS_SUFFIX, Arrays.asList(Aggregates.group(id, Accumulators.sum(count.name(), "$size")))); + facet = new Facet(field + COUNTS_SUFFIX, + Arrays.asList(Aggregates.group( + id, + Accumulators.sum(count.name(), 1), + Accumulators.sum("size", "$size"), + Accumulators.avg("avg", "$size") + ))); break; } case sum: {