Hi,
How do you perform multiple group operations? I tried below, but doesn't seem to work since the second id isn't carried over after the group, for example:
> db.questions.aggregate(
... { $group : {
... _id : "$category_id",
... avg_score : { $avg : "$score" },
... }},
... { $group : {
... _id : "$survey_id",
... avg_score : { $avg : "$score" },
... }}
... );
{
"errmsg" : "exception: the _id field for a group must not be undefined",
"code" : 15956,
"ok" : 0
}
>
This question is cross-posted to Stackoverflow, but hasn't been answered, feel free to reply there if you want the rep:
http://stackoverflow.com/questions/11040662/multiple-group-operations-using-mongo-aggregation-frameworkThanks, Justin