title: MongoDB: Mapreduce: reduce->multiple not supported yet
body: <p>I have a MongoDB collection (named "catalog") containing about 5 astronomical catalogs. Several of these catalogs reference each other, so one of the the documents might look something like this:</p>
  
  <pre><code>{ "_id" : ObjectId("4ec574a68e4e7a519166015f"), "bii" : 20.9519, "class" : 2480, "cpdname" : "CPD -21 6109", "decdeg" : -21.8417, "decpm" : 0.004, "dmname" : "-21 4299", "hdname" : "HD 145612", "lii" : 352.8556, "name" : "PPM 265262", "ppmname" : "PPM 265262", "radeg" : 243.2005, "rapm" : 0.0012, "vmag" : 9.6, "xref" : [ ] }
  </code></pre>
  
  <p>What I want to do is use mapreduce to move the fields such as "hdname","ppmname", etc into the xref array (then unset them).</p>
  
  <p>So I try to do this one at a time, starting with the hdname field. Here are the map and reduce functions:</p>
  
  <pre><code>map = function() {
      for (var hdname in this.hdname) {
          emit(this._id,this.hdname);
      }
  }
  
  
  reduce = function(key, values) {
      var result = [];
      for (var hdname in values) {
          result.push(hdname);
      }
      return result;
  }
  </code></pre>
  
  <p>I try running the following command in the mongo shell:</p>
  
  <pre><code>db.catalog.mapReduce(map, reduce,"catalog2");
  </code></pre>
  
  <p>Unfortunately, I get the following error:</p>
  
  <pre><code>Thu Nov 17 15:52:17 uncaught exception: map reduce failed:{
      "assertion" : "reduce -&gt; multiple not supported yet",
      "assertionCode" : 10075,
      "errmsg" : "db assertion failure",
      "ok" : 0
  }
  </code></pre>
  
  <p>Obviously I'm a newbie... can anyone help?</p>
  
  <p>Jason</p>