title: mongoDB map/reduce minus the reduce
body: <p>I have some 25k documents (4 GB in raw json) of data that I want to perform a few javascript operations on to make it more accessible to my end data consumer (<code>R</code>), and I would like to sort of "version control" these changes by adding a new collection for each change, but I cannot figure out how to <code>map/reduce</code> without the <code>reduce</code>. I want a one-to-one document mapping—I start out with 25,356 documents in <code>collection_1</code>, and I want to end up with 25,356 documents in <code>collection_2</code>.</p>
  
  <p>I can hack it with this:</p>
  
  <pre><code>var reducer = function(key, value_array) {
      return {key: value_array[0]}
  }
  </code></pre>
  
  <p>And then call it like:</p>
  
  <pre><code>db.flat_1.mapReduce(mapper, reducer, {keeptemp: true, out: 'flat_2'})
  </code></pre>
  
  <p>(My mapper only calls emit once, with a string as the first argument and the final document as the second. It's a collection of those second arguments that I really want.)</p>
  
  <p>But that seems awkward and I don't know why it even works, since my <code>emit</code> call arguments in my mapper are not equivalent to the return argument of my <code>reducer</code>. Plus, I end up with a document like</p>
  
  <pre><code>{
      "_id": "0xWH4T3V3R", 
      "value": {
          "key": {
              "finally": ["here"],
              "thisIsWhatIWanted": ["Yes!"]
          }
      }
  }
  </code></pre>
  
  <p>which seems unnecessary.</p>
  
  <p>Also, a cursor that performs its own inserts isn't even a tenth as fast as <code>mapReduce</code>. I don't know MongoDB well enough to benchmark it, but I would guess it's about <code>50x</code> slower. Is there a way to run through a cursor in parallel? I don't care if the documents in my <code>collection_2</code> are in a different order than those in <code>collection_1</code>.</p>