From 57f2138ed35ed6d5237c239f4457b7040d62bcec Mon Sep 17 00:00:00 2001 From: imedina Date: Fri, 13 Dec 2024 02:08:24 +0000 Subject: [PATCH] mongodb: aggregation test 2. To be reverted. --- .../commons/datastore/mongodb/MongoDBQueryUtils.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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: {