Multiple group operations using new aggregate framework?

994 views
Skip to first unread message

Justin Wiley

unread,
Jun 15, 2012, 10:22:06 AM6/15/12
to mongod...@googlegroups.com
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-framework

Thanks, Justin


William Z

unread,
Jun 15, 2012, 1:44:01 PM6/15/12
to mongod...@googlegroups.com
Hi Justin!

I replied on Stack Overflow.

 -William
Reply all
Reply to author
Forward
0 new messages