This article mainly introduces the multi-condition query of mongoDB implemented in Java. It has certain reference value. Friends who need it can refer to it.
Requirements: In the mongDB client, we can easily implement multi-condition query, so how to implement it when using java operation?
Client code:
db.url.find({index:4,status:0,url:{$regex:"2016"}}).limit(1)
java code mainly uses DBObject
BasicDBObject doc5 = new BasicDBObject(); doc5.put("index", 3); doc5.put("status", 0); //doc5.put("url", "{$regex:'2016'}");错误的写法 BasicDBObject doc3 = new BasicDBObject(); doc3.put("$regex", "2016"); doc5.put("url", doc3); FindIterable<document> find = col.find(doc5);</document>
Summary
The above is the detailed content of Implementation case of mongoDB multi-condition query in Java. For more information, please follow other related articles on the PHP Chinese website!