And, or multi-condition query in explain Java
// And, or multi-condition joint query // age condition (and condition) BasicDBList condList = new BasicDBList (); BasicDBObject cond = new BasicDBObject (); cond. put ("$ gt", 0); cond. put ("$ lte", 40); BasicDBObject composeCod = new BasicDBObject (); composeCod. put ("age", cond); condList. add (composeCod); // name condition BasicDBObject nameCond = new BasicDBObject (); nameCond. put ("name", "name"); condList. add (nameCond); // query condition combination (or condition) BasicDBObject searchCond = new BasicDBObject (); searchCond. put ("$ or", condList); DBCursor findRefResult = coll. find (searchCond); int I = 1; while (findRefResult. hasNext () {System. out. println ("Inserted Document:" + I); System. out. println (findRefResult. next (); I ++;} // sort DBCursor cursor = collection. find (filter_dbobject ). limit (10 ). sort (new BasicDBObject ("create_time",-1 ));