//db.role_level_rank.find().sort({"level":-1,"rankTime":1}) MongoClient m1 = new MongoClient("localhost"); DB db = m1.getDB("test"); DBCollection col = db.getCollection("car"); DBObject query = new BasicDBObject("speed", new BasicDBObject("$gt", 40)); // fields with name and speed field is specified and only these fields // are displayed BasicDBObject fields = new BasicDBObject("name", 1).append("speed", 1); DBCursor carCursor1 = col.find(query, fields); try { while (carCursor1.hasNext()) { System.out.println(carCursor1.next()); } } finally { carCursor1.close(); }