When using MapReduce, each resulting document is structured like this
{
"_id" : 123
"value" : 99.95
}
Is there a way to specify other field names? E.g. _id -> sku, value -> price.
MapReduce:
db.runCommand({
mapreduce : "myCollection",
map : function () {
emit( this.sku, this.price );
},
reduce : function (key, values) {
var result = Number.MAX_VALUE;
values.forEach(function(value) {
if (result > value) {
result = value;
}
});
return result;
},
out : { replace : "myReduceTest" }
});
I don’t believe there is and I wonder why you need to change them? With map/reduce you can return objects for both “_id” and “value” which can have fields with whatever names you wish. See examples at http://www.mongodb.org/display/DOCS/MapReduce