0
我试图从春数据蒙戈聚合得到以下查询:如何写春天的MongoDB聚集单个子id字段
{
"_id": {
"year": "$_id.year"
},
"result": {
"$push": {
"rs": "$_id.rs",
"vl": "$vl"
}
}
}
我尝试以下操作:
GroupAggregation as = group("_id.year").push(new BasicDBObject("rs", "$_id.rs").append("vl", "$vl")).as("result");
但它生成此表达在“_id”字段中没有子字段“year”:
{ "$group" : { "_id" : "$_id.year" , "result" : { "$push" : { "rs" : "$_id.rs" , "vl" : "$vl"}}}}
有关如何获得q uery使用spring数据mongodb聚合?
正如你所说,似乎是没有办法做到这一点在纯Spring数据的MongoDB。你的解决方法正在工作。 – Tanrikut