How to get all the document under array in mongodb java. My Database is as below. Want to retrieve all the data under array 198_168_1_134
.
below is some of What i tried,
eventlist.find(new BasicDBObject("$match","192_168_10_17"))
eventlist.find(new BasicDBObject("$elemMatch","192_168_10_17"))
eventlist.find(null, new BasicDBObject("$192_168_10_17", 1))
By using mongo java driver you can do this by following query -
You have two options:
.find()
with cherry-picking which document you have to have fetched.By using
.find()
, you can do:By using the aggregation framework, you can do:
which will fetch only the
192_168_10_17
document data.Of course, in order to get this working in Java, you have to translate these queries to a corresponding chain of
BasicDBObject
instances.