I am working on a MongoDB query
db.BH.group({
"key": {
"AccountId": true,
},
"initial": {
"count": 0
},
"reduce": function(obj, prev) {
if (true != null) if (true instanceof Array) prev.count += true.length;
else prev.count++;
},
"cond":
{"$or":[{"Url":{"$regex":"(google)"}},{"Url":{"$regex":"(facebook)"}}]}
});
The query is working fine in MongoDB Shell(Robomongo).
I have written the same query for python.
db.BH.group({
"key": {
"AccountId": True,
},
"initial": {
"count": 0
},
"reduce": "function(obj, prev) {"
"if (true != null) if (true instanceof Array) prev.count += true.length;"
"else prev.count++;"
"}",
"cond": {"$or":[{"Url":{"$regex":"(google)"}},{"Url":{"$regex":"(facebook)"}}]}
})
But error is coming for the query.
TypeError: group() takes at least 5 arguments (2 given)
I tried to solve the error from the method given in the below website(URL)
http://blog.pythonisito.com/2012/05/aggregation-in-mongodb-part-1.html
But the same error persists.