1、为null或者不存在l
db.test.find({"test":null});
2、不为null并且存在记录
db.test.find({"test":{"$ne":null}});
db.test.find({"test":{"$ne":null, $exists:true}});
3、存在
db.test.find({"test":{$exists:true}});
4、不存在(不会返回null的值)
db.test.find({"test":{$exists:false}});
5、存在且不为null,不为""(空字符串)
List testList = new ArrayList<>();
testList .add(null);
testList .add("");
queryUser.put("test", new BasicDBObject("$nin", testList));