我无法将以下 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").;;
如果有任何帮助,我将不胜感激,谢谢。
最佳答案
Currently there is no support to have $cmp/$eq/$ne to be used in group or project aggregation. It would be a good to have feature. Also it would be helpful to improve on some of the documentation/examples for Criteria features.
关于java - Spring Data MongoDB 聚合转换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19842175/