I am trying to get following query from Spring Data Mongo Aggregation:
{
"_id": {
"year": "$_id.year"
},
"result": {
"$push": {
"rs": "$_id.rs",
"vl": "$vl"
}
}
}
I tried following:
GroupAggregation as = group( "_id.year" ).push( new BasicDBObject( "rs", "$_id.rs" ).append( "vl", "$vl" ) ).as( "result" );
But it generates this expression where there is no sub field "year" under "_id" field:
{ "$group" : { "_id" : "$_id.year" , "result" : { "$push" : { "rs" : "$_id.rs" , "vl" : "$vl"}}}}
Any ideas on how to get that query using spring data mongodb aggregation?