gpt4 book ai didi

java - Spring Data MongoDB 聚合转换?

转载 作者:可可西里 更新时间:2023-11-01 10:32:34 25 4
gpt4 key购买 nike

我无法将以下 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.

请让我们在这里投票:https://jira.springsource.org/browse/DATAMONGO-784

关于java - Spring Data MongoDB 聚合转换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19842175/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com