title: MongoDB query: field either does not exist or has specific value
body: <p>I'd like to query a mongo collection for records which either don't have a value for a field named 'scheme', or explicitly have the value 'http' for 'scheme'. Sounds pretty easy, but this problem has proved more complex than it first appears.</p>
  
  <p>Since <code>db.collection.find({'scheme': None})</code> returns all records where 'scheme' is undefined (no index field), I initially assumed the following would work:</p>
  
  <pre><code>db.collection.find({'scheme': {'$in': ['http', None]}})
  </code></pre>
  
  <p>However, this seems to exclude values in which 'scheme' is undefined, so I can only assume it is searching for records where scheme is either 'http', or explicitly defined to be <code>None</code>. This seems to be a bit counterintuitive, but there we have it. My second attempt was the following:</p>
  
  <pre><code>db.collection.find( {'$or': [{'scheme': {'$exists': False}}, {'scheme': 'http'}]})
  </code></pre>
  
  <p>This also excludes result where scheme is undefined. This time, I can't even think of a logical reason why this is failing.</p>
  
  <p>Any ideas why this is failing, and how I can get it to work as desired?</p>
  
  <p>Thanks</p>
  
  <p>EDIT: Just thought I'd note that I'm performing this query through Python (pymongo), which explains the <code>None</code> (over Javascript's <code>null</code>)</p>