I have some 25k documents (4 GB in raw json) of data that I want to perform a few javascript operations on to make it more accessible to my end data consumer (R
), a
When using map/reduce you'll always end up with
{ "value" : { } }
In order to remove the value
key you'll have to use a finalize
function.
Here's the simplest you can do to copy data from one collection to another:
map = function() { emit(this._id, this ); }
reduce = function(key, values) { return values[0]; }
finalize = function(key, value) { db.collection_2.insert(value); }
Then when you would run as normal:
db.collection_1.mapReduce(map, reduce, { finalize: finalize });