title: PyMongo returns an empty result set when a MongoDB client returns correct results
body: <p>I have a simple <strong>MongoDB</strong> collection that I am accessing using <code>PyMongo</code> in my <strong>Python</strong> script.</p>
  
  <p>I am filtering the query in <strong>Python</strong> using the dictionary:</p>
  
  <pre><code>{ "$and" : [
      { "bettinginterests" : { "$elemMatch" : { "runner.name" : "Jailhouse King" } } },
      { "bettinginterests" : { "$elemMatch" : { "runner.name" : "Tyrone Haji" } } }
      ]
  }
  </code></pre>
  
  <p>And this returns correct results. However, I would like to expand the filter to be:</p>
  
  <pre><code>{ "$and" : [
      { "bettinginterests" : { "$elemMatch" : { "runner.name" : "Jailhouse King" } } },
      { "bettinginterests" : { "$elemMatch" : { "runner.name" : "Tyrone Haji" } } },
      { "summary.dist" : "1" }
      ]
  }
  </code></pre>
  
  <p>And this is returning an empty result set. Now when I do this same query in my <strong>MongoDB</strong> client using:</p>
  
  <pre><code>db.race_results.find({ "$and" : [
      { "bettinginterests" : { "$elemMatch" : { "runner.name" : "Jailhouse King" } } },
      { "bettinginterests" : { "$elemMatch" : { "runner.name" : "Tyrone Haji" } } },
      { "summary.dist": "1" }
      ]
  })
  </code></pre>
  
  <p>The results are returned correctly as expected.</p>
  
  <p>I don't see any difference between the <strong>Python</strong> dictionary being passed as the query filter, and the <code>js</code> code being executed on my <strong>MongoDB</strong> client.</p>
  
  <p>Does anyone see where there might be a difference? I'm at a loss here.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Here is a sample record in my DB:
  <a href="https://gist.github.com/brspurri/8cefcd20a7f995145a81" rel="nofollow">https://gist.github.com/brspurri/8cefcd20a7f995145a81</a></p>
  
  <p><strong>UPDATE 2:</strong>
  Python Code to perform the query:</p>
  
  <pre><code>runner = "Jailhouse King"
  opponent = "Tyrone Haji"
  query_filter = {"$and": [
                      {"bettinginterests": {"$elemMatch": {"runner.name": runner}}},
                      {"bettinginterests": {"$elemMatch": {"runner.name": opponent}}},
                      { "summary.dist" : "1" }
                      ]
                  }
  
  try:
      collection = db.databases['race_results']
      entities = None
      if not query_filter:
          entities = collection.find().sort([("date", -1)])
      else:
          entities = collection.find(query_filter).sort([("date", -1)])
  
  except BaseException, e:
      print('An error occured in query: %s\n' % e)
  </code></pre>