title: Indexing of Object keys in MongoDB
body: <p>I have this structure</p>
  
  <pre><code>{
      "_id": "willwill",
      "rental": {
          "hitchhikergalaxy": {[...]},
          "animalfarm": {[..]}
      }
  }
  </code></pre>
  
  <p>Which <code>[..]</code> is a embedded document storing the details of the rental (and the exactly same data also exists on another collection) and the <code>rental</code> Object's keys are <code>_id</code> of the <code>book</code> collection.</p>
  
  <p>How do I <code>ensureIndex()</code> this query?</p>
  
  <pre><code>db.users.find({"rental.animalfarm": {'$exists': true}})
  </code></pre>
  
  <p>(I use MongoDB on PHP, but the example above is in JavaScript)</p>