I am trying to get the number of documents that have a field with an empty string. This field allows you to call it "Field_One" is present in all documents (therefore, to be clear, I am not trying to find whether this field exists or not, I want to find which documents have nothing (empty line) in the field "Field_One" " .
I tried using (using the C # driver):
collection.Find(Query.NE("Field_One", BsonNull.Value)).Count() collection.Find(Query.NE("Field_One", BsonString.Null)).Count()
and even (someone suggested this somewhere):
collection.Find(Query.GT("Field_One", BsonString.Empty)).Count()
But this will not work (they return all documents).
Also, as a related question: Is this the best way to get the number of matching documents in a collection? As far as I understand, it usually does not extract documents from the database into my program, so the counter is calculated on the MongoDB server.
source share