Aggregation Framework over document

18 views
Skip to first unread message

Igo88

unread,
Jan 26, 2012, 10:47:25 AM1/26/12
to mongodb-user
Suppose i have a map reduce procedure, in which on the finalize option
i would like to group some value by type...is possible to execute an
"aggreate" command over a document or i have to pass a
collection?...if that is possible i could do something like this:

var finalize = function (key, value) {
value.grouped = db.runCommand(
{ aggregate : value, pipeline : [
{ $project : {
"value.data" : 1
}
},
{ $unwind : "$value.data" },
{ $group: {
_id: { a: "$value.data.t", b: "$value.data.objid" },
relatedActivities: { $addToSet : "$value.data.id" }
}
}
]
});
return value;
}

if that is impossible how would you do it?...Thanks in advance.

Scott Hernandez

unread,
Jan 26, 2012, 10:55:27 AM1/26/12
to mongod...@googlegroups.com
You should not mix map/reduce and the aggregate framework. Just do it
with the aggregation framework completely.

If you post the rest of your map/reduce someone might be able to help
you with a sample.

> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>

Igo88

unread,
Jan 26, 2012, 11:13:11 AM1/26/12
to mongodb-user
Thanks for your answer...the thing is group by on the aggregation
framework is held on memory i have fairly large collection to compute.
My idea is to perform the map reduce or the aggregation command and
then store it on another collection to query.

i would test if i can do the trick only with the aggregation
framework, but it is a limitation for me, that $group is based on
memory only.

Igo88

unread,
Jan 26, 2012, 11:27:32 AM1/26/12
to mongodb-user
I have converted my map reduce function into an aggregation command,
but i cant use the $out operator yet...i would like the $output:reduce
that has the map reduce function.

Thanks.

Scott Hernandez

unread,
Jan 27, 2012, 8:47:39 AM1/27/12
to mongod...@googlegroups.com
Yes, the framework is not complete yet (or released), and not all
features which might be needed have been added or prioritized. Please
feel free to make sure a feature request exists for this use-case for
the aggregation framework: http://jira.mongodb.org/browse/SERVER
Reply all
Reply to author
Forward
0 new messages