how to search the array with no empty value from mongodb in java?

浪子不回头ぞ 提交于 2019-12-14 02:31:52

问题


I would like to get the data tags from mongodb whose data is not null "tags" : [ ]

I tried doing $ne but no chance.

BasicDBObject searchQuery = new BasicDBObject();
searchQuery.put("tags", new BasicDBObject("$ne", []));

Any help would be appreciated.


回答1:


I solved this by using this query
searchQuery.put("tags.1", new BasicDBObject("$exists", true));



来源:https://stackoverflow.com/questions/42099824/how-to-search-the-array-with-no-empty-value-from-mongodb-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!