如何在java中查询存在MongoDB里的嵌套json格式的数据?这是我的json数据:{ "_id" : ObjectId("59eac603b2921c583a1a38c1"), "mj1" : { "source" : 104963,"dj":"mih", "number" : 3, "target" : 100322,"weights" : 122 }, "mj2" : { "source" : 109601,"dj":"mih", "number" : 4, "target" : 105710,"weights" : 10 } }{ "_id" : ObjectId("59eac6b7b2921c583a1a38cd"), "mj1" : [ { "source" : 104963,"dj":"mih","number" : 3, "target" : 100322,"weights" : 1022 },"mj2" : { "source" : 109601,"dj":"mih", "number" : 4, "target" : 105710,"weights" : 2 } ] }我先用了这句话( db.mjj.find({"mjj1":{"$ne" : null,$exists : true}}))查询,可以得到如上结果,但是,我只想查询"source","number","target",这三样,该如何编写程序?CMD的命令和JAVA的命令回答都可以。
1 回答
ibeautiful
TA贡献1993条经验 获得超5个赞
db.mjj.find({"$and": [{mj1.source: 12345}, {mj1.number: 22345}, {mj1.target: 32345}]}
添加回答
举报
0/150
提交
取消