I have a number of documents which look like this:
{userId: 123, msg:{ timestamp:123456, event:"actionA"} }
{userId: 123, msg:{ timestamp:123466, event:"actionB"} }
etc...
Map fn:
emit(doc.userId, [doc.msg])
Reduce fn:
return [].concat.apply([], vs)
These functions seem to do what I expect, so I'd thought I'd see output like:
Key: 123, Value: [{timestamp:123456, event:"actionA"}, {timestamp:123466, event:"actionB"}, ...etc...]
But, I am getting a reduce overflow error, "Reduce output must shrink more rapidly". Indeed, the couchdb docs say that "As a rule of thumb, the reduce function should reduce to a single scalar value." ... "CouchDB will give you a warning if you try to use reduce “the wrong way”".
So, I guess I'm using Couch MR the "wrong way". What would be the "right way" to do this kind of calculation?