mclog@mc-arch-mongo-ems-172-17-0-6> var match ={"$match":{"clickid" : /^2812.1502768165176$/}};
mclog@mc-arch-mongo-ems-172-17-0-6> var group= {$group : {_id : {"campai gn_id":"$campaign_id"},"ipset":{$addToSet : "$ip"}}}
mclog@mc-arch-mongo-ems-172-17-0-6> db.click_20170815.aggregate([group,match])
-------------------------------------------------------------------------------------
[thread1] Error: command failed: {
"ok" : 0,
"errmsg" : "Exceeded memory limit for $group, but didn't allow external sort. Pass allowDiskUse:true to opt in.",
"code" : 16945
} : aggregate failed :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:16:14
assert.commandWorked@src/mongo/shell/assert.js:370:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1319:5
-------------------------------------------------------------------------------------
try : db.click_20170815.aggregate([group,match],{allowDiskUse:true})
db.conversion_20170906.aggregate([{"$match":{"_id" : /^3380.*$/}},{"$group":{"_id":"$campaign_id","s1_counts":{"$sum":1},"s1_sets":{"$addToSet":"$s1"}}},{$match:{"s1_counts":{$gt:4}}}])
-------------------------------------------------------------------------------------
work :
mclog@mc-arch-mongo-ems-172-17-0-6> var match ={"$match":{"_id" : /^3380.*$/}};
mclog@mc-arch-mongo-ems-172-17-0-6> var group= {$group : {_id : "$campaign_id","ipset":{$addToSet : "$ip"}}}
db.conversion_20170906.aggregate([match,group])
{ "_id" : "3380", "ipset" : [ "14.116.141.129", "14.116.142.199", "106.39.191.65", "14.116.142.83", "218.18.147.233", "59.54.47.246", "14.215.160.152", "14.21
5.160.93", "116.226.19.165", "106.39.189.241", "119.39.18.25", "106.39.191.44", "223.104.94.26", "14.152.69.176", "14.116.141.63", "223.104.24.115", "14.152.6
9.107", "14.215.160.238", "211.103.82.151", "124.239.176.61", "175.188.164.228", "175.188.162.90", "223.104.10.29", "14.152.69.84", "116.226.119.56", "117.136
.45.152", "211.103.82.178", "14.152.68.164" ] }