Search documents with a missing field

  • by
db.articles.find({"article_id":{$exists: false}})
db.articles.find({"article_id":{$exists: false}}).count()

Searching documents with an explicit field

db.articles.find({"article_id":{$exists: true}})
db.articles.find({"article_id":{$exists: true}}).count()

Source

https://docs.mongodb.com/manual/reference/operator/query/exists/