-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.5.0, 3.6.0
-
Component/s: BSON
-
Environment:Windows 8.1 - IDE Eclipse Java - Java 8 - MongoDB 3.4.9
Accumulators dosn't work as they should, they just replace the value given instead to process it.
Example:
Document document = new Document("firstname", "Pedro")
.append("lastname", "Doe")
.append("age", 14)
.append("country", "Tanzania")
.append("index", 1);
collection.insertOne(document);
List<Bson> query= asList(Aggregates.match(Filters.eq("firstname", "Pedro")),Aggregates.group("$_id", Accumulators.avg("age", 100), Accumulators.sum("index", 100)));
AggregateIterable<Document> resuls t= collection.aggregate(query);
for(Document d : results)
-Result:
{ "_id" :
, "age" : 100.0, "index" : 100 }
-expected:
{ "_id" :
, "age" : 57.0, "index" : 101}