1.
I know how to query with JavaScript expression in Mongo shell
( collection name is resource_phys. field name is val which defined as String type and contains only numeric value ) :
//in Mongo shell:
var query1 = ("Number(this.val)>-1 && Number(this.val)<3")
db.resource_phys.find(query1)
//result found
2. Now, I want to do the same thing in Java code but cannot find any API to support JavaScript. I solicit your help to give some hints.
3.P.s.
If the field val is numeric type, I am aware of using operator $gt and $lt :
//in Java codes:
DBCollection coll = db.getCollection("resource_phys");
DBObject query2 = new BasicDBObject("val",new BasicDBObject("$gt",-1).append("lt",3));
DBCursor cursor = coll.find(query2);
//result got in cursor