我无法将mongodb聚合操作转换为Spring Data AggregationOperation。我使用的是Spring Data MongoDB 1.3.2版本。
db.ads.aggregate( { $group :{
_id : "$adId",
req : { $sum : 1 },
imp: {$sum: { $cond: [ { $eq: [ "$imped", true ] } , 1, 0 ] } },
click: {$sum: { $cond: [ { $eq: [ "$clked", true ] } , 1, 0 ] } } ,
bid: {$sum: { $cond: [ { $eq: [ "$clked", true ] } , "$bid", 0 ] } } } });
我在这里停了下来:
AggregationOperation group = Aggregation.group("adId").count().as("req").sum("imped").as("imp").;;
感谢您的帮助,谢谢。
答案 0 :(得分:2)
目前没有支持在组中使用$ cmp / $ eq / $ ne 或项目聚合。有功能会很好。还有 将有助于改进一些文档/示例 标准特征。