title: Create text index on sub-document field wildcard
body: <p>I am experimenting with creating a text index in MongoDB for several fields in a sub-document.  These fields are not the same from document to document.  <a href="http://docs.mongodb.org/manual/tutorial/create-text-index-on-multiple-fields/" rel="noreferrer">According to the documentation</a>, I would create a normal text index like so:</p>
  
  <pre><code>db.collection.ensureIndex({
      subject: "text",
      content: "text"
  });
  </code></pre>
  
  <p>In my case, I want the index on all fields in the <code>fs.files</code> collection at <code>db.fs.files.metadata</code>.  I've tried this:</p>
  
  <pre><code>db.fs.files.ensureIndex({'metadata.$**': 'text'});
  </code></pre>
  
  <p>I don't believe this has worked, as searching with <code>db.fs.files.runCommand('text'...</code> returns zero results, and <code>db.fs.files.stats()</code> shows the index as a very small size (and I have ~35k documents in this collection).</p>
  
  <p>How can I create a text index on field values of a subdocument where the keys are not known ahead of time?</p>