Question

I couldn't convert below mongodb aggregate operation to Spring Data AggregationOperation. I am using Spring Data MongoDB 1.3.2 version.

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 ] } } } });

I stopped here:

AggregationOperation group = Aggregation.group("adId").count().as("req").sum("imped").as("imp").;;

I would appreciate any help, thanks.

Was it helpful?

Solution

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.

please let's vote in here: https://jira.springsource.org/browse/DATAMONGO-784

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top