Passing Arguments to MapReduce

646 views
Skip to first unread message

marcus

unread,
Nov 1, 2009, 7:49:29 PM11/1/09
to mongodb-user
Is it possible to pass arguments to the map function in a mapreduce
call?

Something like this does not work for me:

> results = db.runCommand({mapreduce: "things", map:m('dog'),reduce:r});
undefined
Sun Nov 1 18:44:12 JS Error: TypeError: str has no properties (shell):
3

> results = db.runCommand({mapreduce: "things", map:m,reduce:r});
{
"result" : "tmp.mr.things_1257122656_17",
"timeMillis" : 34,
"counts" : {
"input" : 3,
"emit" : 2,
"output" : 2
},
"ok" : 1
}

Thanks,
Marcus

Eliot Horowitz

unread,
Nov 1, 2009, 8:13:25 PM11/1/09
to mongod...@googlegroups.com
No - no way to do that yet.
Added a case though: http://jira.mongodb.org/browse/SERVER-401

marcus

unread,
Nov 1, 2009, 11:52:32 PM11/1/09
to mongodb-user
Slated for 1.1.4!... Awesome! Thanks... it should really help with
the project I'm working on.

Marcus

VJ

unread,
Apr 3, 2012, 5:00:18 PM4/3/12
to mongod...@googlegroups.com
Hello.  I know that this is a really old ticket, but I'm having the same problem.  Does anyone have an example of passing a parameter into a map function?
Thanks.

Sam Millman

unread,
Apr 3, 2012, 5:40:01 PM4/3/12
to mongod...@googlegroups.com
You add them in the scope property of the of the MR call: http://www.mongodb.org/display/DOCS/MapReduce

They go into globa so passing (in PHP):

array('woop' => $cheese)

will be "woop" in your map.

If you are having problems understanding can you paste your MR call and map?

--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/A56sPfgN2DcJ.
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.

Reply all
Reply to author
Forward
0 new messages