I'm using pymongo version 2.7.2.
I just want to count occurrences by name matching by Hostname.
I don't want to use map/reduce. I want to do it through aggregate function.
Executing this query:
"Counting by name matching by Hostname"
cursor = self.coll.aggregate(
{"$match": {"HOSTNAME": "XXYYX"}},
{"$group": {"_id": {"Name": "$NAME"}, "count": {"$sum": 1}}},
)
I got the following error:
line 46, in registerApps
"count": { "$sum": 1 }
TypeError: aggregate() takes 2 positional arguments but 3 were given
This query is perfectly running over mongodb. But I don't know how to translate it properly to Pymongo.
Could you help me on this?
Thanks very much!