聚合语句测试match,group

var match ={"$match":{"_id" : /^2812.*$/}};

var match ={"$match":{"_id" : /^3806.*$/}};

var match ={"$match":{"clickid" : /^2812.*1502768165176$/}};

var group= {$group : {_id : "$campaign_id","ip_count":{$sum : 1},"ipset":{$addToSet : "$ip"}}};

var group= {$group : {_id : "$campaign_id","ipset":{$addToSet : "$ip"}}}

db.conversion_20170906.aggregate([{"$group":{"_id":"$campaign_id","s1_counts":{"$sum":1},"s1_sets":{"$addToSet":"$s1"}}},{$match:{"s1_counts":{$gt:4}}}])

db.conversion_20170906.aggregate([{"$match":{"_id" : /^3380.*1.*$/}},{"$group":{"_id":"$campaign_id","s1_counts":{"$sum":1},"s1_sets":{"$addToSet":"$s1"}}},{$match:{"s1_counts":{$gt:4}}}])

[{"$group":{"_id":{"campaign_id":"$campaign_id","s1":"$s1"},"s1_counts":{"$sum":1},"s1_sets":{"$addToSet":"$s1"},}},{"$project":{"_id":0,"s1":"$s1","groupby":"$_id","s1_total":"$s1_counts"}}])

db.conversion_20170906.aggregate([group,match],{allowDiskUse:true})

db.click_20170815.aggregate(match,{$group : {_id : {"campaign_id":"$campaign_id"},"ipcount":{$sum : 1},"ipset":{$addToSet : "$ip"}}})

db.click_20170815.aggregate(match,{$group : {_id : {"campaign_id":"$campaign_id"},"ipcount":{$sum : 1},"ipset":{$addToSet : "$ip"}}})

你可能感兴趣的:(聚合语句测试match,group)