title: combining regex and embedded objects in mongodb queries
body: <p>I am trying to combine regex and embedded object queries and failing miserably. I am either hitting a limitation of mongodb or just getting something slightly wrong maybe someone out ther has encountered this. The documentation certainly does'nt cover this case.</p>
  
  <p>data being queried:</p>
  
  <pre><code>{
      "_id" : ObjectId("4f94fe633004c1ef4d892314"),
      "productname" : "lightbulb",
      "availability" : [
              {
                      "country" : "USA",
                      "storeCode" : "abc-1234"
              },
              {
                      "country" : "USA",
                      "storeCode" : "xzy-6784"
              },
              {
                      "country" : "USA",
                      "storeCode" : "abc-3454"
              },
              {
                      "country" : "CANADA",
                      "storeCode" : "abc-6845"
              }
      ]
  }
  </code></pre>
  
  <p>assume the collection contains only one record</p>
  
  <p>This query returns 1:</p>
  
  <pre><code>db.testCol.find({"availability":{"country" : "USA","storeCode":"xzy-6784"}}).count();
  </code></pre>
  
  <p>This query returns 1:</p>
  
  <pre><code>db.testCol.find({"availability.storeCode":/.*/}).count();
  </code></pre>
  
  <p><strong>But, this query returns 0</strong>:</p>
  
  <pre><code>db.testCol.find({"availability":{"country" : "USA","storeCode":/.*/}}).count();
  </code></pre>
  
  <p>Does anyone understand why? Is this a bug? </p>
  
  <p>thanks</p>