I’ll introduce a query to get documents where a specific text field has x or more characters in MongoDB.

db.users.find( { name : { $ne: null }, $where: "this.name.length > 5" } )
The key point is checking the length with $where only when the name field has a value.
That’s all from the Gemba.