Aggregation with JAVA

There is not enough information available on documentation about “GROUP By” in JAVA language.You should provide some better example and brief explanation about all Aggregation operation so that everyone can understand easily.
We can use GROUP by with DBObject also but in GROUPOPERATION method, It is fatigue task to do as it is not easily understandable.
I hope, You may see this request and take immediate action.

Thank you…

One thing that helped me a lot with aggregation is the course M121 - The MongoDB Aggregation Framework from

I also use to built my pipelines.

Finally, since I have projects in Java, some in nodejs and use the shell on daily basis, I keep my aggregation pipelines in json, even in Java where I do not use the aggregation builder classes.


I second @steevej on both M121 and compass.

You can try the newer (and easy to use) com.mongodb.client.model.Aggregates aggregation pipeline builder class’s group methods. Also see Aggregation Tutorials and Example usage of Aggregates.

As of Java driver v3.9 GroupOperation is deprecated.

Compass’s Aggregation Pipeline Builder has Export Pipeline to Specific Language feature, and this allows the built pipeline to be converted to corresponding Java code.

1 Like

In Java, for same DTO above bold query works fine. Can you please give me reason behind this and also how this fields works?

collection’s document is :