admin mongo查询注意

campid;需要双引号

db.conversion_20171101.aggregate([{$match:{campaign_id:"4750"}},{$group : {_id : {"campaign_id":"$campaign_id","s1":"$s1", total : {$sum : 1}}}}])

db.conversion_20171101.aggregate([{$match:{n_id:316}},{$group : {_id : {"n_id":"$n_id","s1":"$s1", total : {$sum : 1}}}}])

db.conversion_20171101.aggregate([{$match:{offer_id:1954}},{$group : {_id : {"offer_id":"$offer_id","s1":"$s1", total : {$sum : 1}}}}])

注意上一个使用了_id包含所有 所以total的值是1(因为被当做分组条件了)
下面的才能得到正确的total:

db.conversion_20171101.aggregate([{$match:{offer_id:1954}},{$group : {_id : {"offer_id":"$offer_id","s1":"$s1"}, total : {$sum : 1}}}])

你可能感兴趣的:(admin mongo查询注意)