title: Aggregate distinct values in MongoDB
body: <p>I have a mongodb db with 18625 collections. It has following keys:</p>
  
  <pre><code>    "_id" : ObjectId("5aab14d2fc08b46adb79d99c"), 
      "game_id" : NumberInt(4), 
      "score_phrase" : "Great", 
      "title" : "NHL 13", 
      "url" : "/games/nhl-13/ps3-128181", 
      "platform" : "PlayStation 3", 
      "score" : 8.5, 
      "genre" : "Sports", 
      "editors_choice" : "N", 
      "release_year" : NumberInt(2012), 
      "release_month" : NumberInt(9), 
      "release_day" : NumberInt(11)
  </code></pre>
  
  <p>Now, i wish to create another dimension/ collection with only genres.</p>
  
  <p>If i use the following query :</p>
  
  <pre><code>db.ign.aggregate([ {$project: {"genre":1}}, { $out: "dimen_genre" } ]);
  </code></pre>
  
  <p>It generates 18625 collections, even though there are only 113 distinct
  genres.</p>
  
  <p>How to apply distinct here and get the collection for genres with only the distinct 113 values.
  I googled, bt it showed that aggregate and distinct don't work together in mongo. 
  I also tried : db.dimen_genre.distinct('genre').length
  this showed that in dimension_genre, there are 113 distinct genres.</p>
  
  <p>Precisely, 
  how to make a collection from existing one with only distinct values.</p>
  
  <p>I am really new to NoSQLs.</p>