title: $elemmatch not working in MongoDB
body: <p>I am trying to filter mongo data by using the below query in mongodb version 2.6.1 but getting error.</p>
  
  <p>MongoDB version 2.4.6 (Working):</p>
  
  
  
  <pre class="lang-js prettyprint-override"><code>&gt; db.BC_1839.find({data: {$elemMatch:{$where : "this.First_name.toLowerCase().indexOf('kim') ==0"}}});
  </code></pre>
  
  <p>output:</p>
  
  <pre class="lang-js prettyprint-override"><code>{ 
      "_id" : ObjectId("53719a9d5b9e5c8c110001b9"),
      "data" : [
          {
              "First_name" : "Kimberely",
              "Last_name" : "Weyman",
              "Company_name" : "Scientific Agrcltl Svc Inc",  
              "Address" : "7721 Harrison St",
              "City" : "Kingsway West",
              "State" : "NS",
              "Post" : "2208",   
              "Phone1" : "02-7091-8948",   
              "Phone2" : "0441-151-810", 
              "Email" : "kweyman@weyman.com.au",
              "Web" : "http://www.scientificagrcltlsvcinc.com.au", 
              "active" : "true"
          } 
      ], 
      "history" : [    
          { 
              "timestamp" : "2014-05-13 06:07:55",
              "event": "creation",
              "createdby" : "Srikesh Infotech",
              "creation_data" : [
                  {
                      "crm_base_contact_id" : "1839",
                      "crm_imported_files_id" : "1464"
                  }  
              ] 
          },
          {
              "timestamp" : "2014-05-13 06:09:05",
              "event" : "Task",
              "createdby" : "Srikesh Infotech",
              "Task_data" : [ 
                  {
                      "Campaign ID" : "193",  
                      "Campagin Name" : "Test Campa1"
                  }
              ]
          }
      ], 
      "ref" : [ 
          { "crm_base_contact_id" : "1839", "crm_imported_files_id" : "1464" }
      ]
  }
  </code></pre>
  
  <p>MongoDB version 2.6.1(Not Working):</p>
  
  <pre class="lang-js prettyprint-override"><code>&gt; db.BC_1839.find({data: {$elemMatch:{$where : "this.First_name.toLowerCase().indexOf('kim') ==0"}}});
  </code></pre>
  
  <p>output:</p>
  
  <pre class="lang-js prettyprint-override"><code>error: {
          "$err" : "Can't canonicalize query: BadValue $elemMatch cannot contain $
  where expression",
          "code" : 17287
  }
  </code></pre>
  
  <p>Same query executes in mongodb version 2.4.6 but not in mongodb version 2.6.1 Why???</p>