title: Multi-key Indexing on an Entire Array
body: <p>MongoDB's <a href="http://docs.mongodb.org/manual/core/index-multikey/" rel="nofollow noreferrer">docs</a> explain multi-key indexing. Consider this <code>comment</code> document.</p>
  
  <pre><code>{
   "_id": ObjectId(...)
   "title": "Grocery Quality"
   "comments": [
      { author_id: ObjectId(...)
        date: Date(...)
        text: "Please expand the cheddar selection." },
      { author_id: ObjectId(...)
        date: Date(...)
        text: "Please expand the mustard selection." },
      { author_id: ObjectId(...)
        date: Date(...)
        text: "Please expand the olive selection." }
   ]
  }
  </code></pre>
  
  <p>The docs explain that it's possible to index on the <code>comments.text</code>, or any <code>comments</code>' field. <strong>However, is it possible to index on the <code>comments</code> key itself?</strong> </p>
  
  <p>This <a href="https://stackoverflow.com/questions/7396219/mongodb-multikey-indexing-structure">post</a> demonstrates indexing on an array of strings, however, the above <code>comments</code> field is an <strong>array of JSON objects</strong>.</p>
  
  <p>Based on Antoine Girbal's <a href="http://edgystuff.tumblr.com/post/47178201123/mongodb-indexing-tip-3-too-many-fields-to-index-use" rel="nofollow noreferrer">article</a>, it appears possible to index on an array of JSON objects where each JSON object has a <strong>different</strong> key name. However, it doesn't appear possible where each JSON object in the array shares the same key names.</p>
  
  <p>Example - <a href="https://gist.github.com/kman007us/6797422" rel="nofollow noreferrer">https://gist.github.com/kman007us/6797422</a></p>