3

I'm trying to use map-reduce on a large set of documents where for each document there are a few fields which I want to gather into an array. (array for each field type). I thought that map-reduce is the right pattern for this job but I am receiving the following error:

planSummary: COUNT keysExamined:0 docsExamined:0 exception: value too large to reduce 
code:13070 numYields:3025579 reslen:98 locks:{ Global: { acquireCount: { r: 17765206, w: 5104556 } }, 
Database: { acquireCount: { r: 1627, w: 5104550, R: 6328698, W: 9 }, acquireWaitCount: { w: 1 }, timeAcquiringMicros: { w: 382 } }, 
Collection: { acquireCount: { r: 1627, w: 5104553 } } } protocol:op_command 64490380ms

Any idea on how to debug or force it to work?

** EDIT ** Adding the map and reduce function and the general build of the documents.

var map = function() {  key = [this.k1, this.k2, this.k3];   emit(key, this); };
var red = function(key, documents){
    var result = documents[0];
    var x1 = [result.x1];
    ...
    var xn = [result.xn];
    for (i = 1; i < documents.length; i++){
        x1.push(documents[i].x1);
        ...
        xn.push(documents[i].xn);
    }
    result.x1 = x1;
    ...
    result.xn = xn;
    return result;
};

I can't put sample objects but they are built as 3 fields are keys and the others are values which should become a list as is done in the reduce function.

Thanks

sidgate
  • 14,650
  • 11
  • 68
  • 119
Eytan
  • 728
  • 1
  • 7
  • 19
  • 1
    You need to show the actual code you are using, and some indication of the data you are working with and the expected result. Generally speaking, `mapReduce` should really only be used when you cannot apply `.aggregate()`, and in modern releases there are very few cases where that cannot be applied. – Neil Lunn Aug 27 '17 at 09:22

0 Answers0