title: Simple MongoDB query on HASH not working as expected (only in some conditions)
body: <p>Ok, it's a bit complex so i'll try to be clear. </p>
  
  <p>I have a structure I use to build some sort of ticket system. </p>
  
  <p>Parent Collection: Thread </p>
  
  <p>Embedded Collection: Message (a Thread embeds 0..N Messages) </p>
  
  <p>In a message I have an attribute "read_time" of type HASH where the 
  keys are the OID of a user and the values a datetime. 
  A sample set of data for a Thread would look like </p>
  
  <pre><code>_id                   "4e9806c223349f0001000044" 
  author_id            {"$oid": "4e8b281429e167765d00001a"} 
  created_at           2011-10-14 09:54:10 UTC 
  ref                  252 
  status       "open" 
  ... 
  messages 
                      [ 
                        0 
                            { 
                            _id                  {"$oid":     "4e9806c223349f0001000045"} 
                            author_id            {"$oid":     "4e8b281429e167765d00001a"} 
                            content              "Hello" 
                            created_at    2011-10-14 09:54:11 UTC 
                            read_time 
                                                 { 
                                                       4e8b281429e167765d00001a           2011-10-14 09:54:11 UTC
                                                       4d5a7dfe29e1674958000013           2011-10-14 11:48:18 UTC
                                                       4d5a62ac29e1676226000050     2011-10-15 06:44:21 UTC 
                                                 } 
                            }, 
                      1 
                            { 
                            _id                  {"$oid":   "4e9806c223349f0001000046"} 
                            author_id            {"$oid":   "4e8b281429e167765d00001a"} 
                            content              "Hello 2" 
                            created_at    2011-10-14 09:54:11 UTC 
                            read_time 
                                                 { 
                                                       4e8b281429e167765d00001a           2011-10-15 09:54:11 UTC 
                                                       4d5a7dfe29e1674958000013           2011-10-16 11:48:18 UTC 
                                                 } 
                            } 
                      ] 
  </code></pre>
  
  <p>The idea here is to build a query to only the threads that are UNREAD 
  for a given author. With the example given above, the user with OID 
  4d5a62ac29e1676226000050 has read the first message of the thread but 
  not the second (as the read_time hash does not contain an entry for 
  the key "4d5a62ac29e1676226000050"). </p>
  
  <p>My query looks likes this, which is pretty straight forward in my 
  opinion and should work flawlessly but the results are quite 
  unexpected.... </p>
  
  <pre><code>{ "support_messages.read_time.4d5a62ac29e1676226000050" : { "$exists" : false} } 
  </code></pre>
  
  <p>Simply put, I query all the Threads that contains at least one message 
  that does not have a key of "4d5a62ac29e1676226000050" in it's 
  read_time attribute. </p>
  
  <p>The weird part now... is that this query works, but not all the time ! 
  It only returns a subset of the threads that I am expecting to see. I 
  haven't been able to determine an exact pattern yet for the cases that 
  don't work, but it seems that when there are more than one Messages in 
  a thread and that "many" other users have read them, but not the user 
  I am querying for, then the Thread in question does not appear in the 
  results... I have no idea why. If I am querying the documents manually 
  I see all the data I am expecting (just like the example above), but 
  the Thread is simply ignored... </p>
  
  <p>Please help ! </p>
  
  <p>Alex </p>