If you trying to query some additional info from another collection(for example "foo") for "map" callback,
it works only if there is copy of "foo" at every shard, that will run this MR job.
Is it right or not?
Even if you create "Mongo" instance like this "new Mongo('host:port');" ?
Code for reproduce this:
// foo db.foo.insert({foo: 1}); db.foo.insert({foo: 2}); // sharding sh.enableSharding('current_db'); sh.shardCollection('current_db.barSharded', {_id: 1}); // insert 10m rows for (var i = 0; i < 10000000; ++i) { db.barSharded.insert({i: i}); } var map = function() { var db = (new Mongo()).getDB(database); if (!db.foo.findOne()) { throw "reproduced"; } } var reduce = function(rows) {} db.barSharded.mapreduce(map, reduce, {out: "baz"});