0

I have a couchdb view with a reduce function

function(doc) {
   if (doc.type === 'item') {

        emit(doc.storeid + '-' + doc.feedid, parseInt(doc.sku));
   }
}

The above query returns more than 30K results

My reduce function

function (key, values, rereduce) {

   if (key.length > 1) {
       var valueArray = new Array();
       for (var i = 0; i < key.length; i++) {
            valueArray.push(values[i]);
       }
       return valueArray;
   } else {
       return values;
   }
}

The above reduce function returns the results as below

 Key          |        Value
 1234-5642    |    [3232,54235,346332,34656,23425,443256343,234235,231]
 0933-3122    |    [34323,64343,1111]

However, where a single Key has more records say 30K+ the ARRAY values is NULL. Any suggestions on how best to improve the reduce function to return the values in the above results?

vyeluri5
  • 487
  • 5
  • 8
  • 18
  • 1
    You forgot to handle the `rereduce` case, that might have something to do with this. But you really shouldn't use a `reduce` function for this, just assemble the list of values from the output of your map function. – Dominic Barnes May 08 '16 at 03:00
  • `values` param in the reduce function is an array so you could simply do `return values;` in your reduce function. If you clarify what you are trying to achieve, in a bit broader context, might able to get you better answers.. – seb May 14 '16 at 09:25

0 Answers0