Why doesn't mongo count add up?
Does anyone know why mongodb is returning a weird result when doing the next 3 queries? It seems that the result of the first and second counts should be equal to the third, but it is not. All I do is count the number of documents containing a specific field + those that do not contain that field. I expect this to be equal to the total number of documents:
> db.col1.find({f1:{$exists:false}}).count()
0
> db.col1.find({f1:{$exists:true}}).count()
267837
> db.col1.count()
268185
+3
source to share