On 26/03/15 07:11, Russell McOrmond wrote:

   For most of the hundreds of thousands of keys, the reduce function has
nothing to return -- and I'd like to quickly skip over them and get to the
few keys where I did have something to return.

You should define a way to aggregate the documents produced by the map function at an higher level, since at the un-grouped level there must be one result per document.

For instance, this reduce function does return empty arrays when the name attribute does not contain "fer" and the level is un-grouped, but drops the empty arrays when grouping, reducing the output significantly (OK, depending on the data you've got):

function (keys, values, rereduce) {
 var result= [];
 if (rereduce === false) {
   values.forEach(function(v) {
     if (v.name.indexOf("fer") !== -1) {
       result.push(v.name);
     }
   });
 } else {
   values.forEach(function(v) {
     if (v.length > 0) {
       result= result.concat(v);
     }
   });
 }
 return result;
}

Hope this helps.

Regards,

Luca Morandini
Data Architect - AURIN project
Melbourne eResearch Group
Department of Computing and Information Systems
University of Melbourne
Tel. +61 03 903 58 380
Skype: lmorandini

Reply via email to