Preethi Jain Preethi Jain - 8 months ago 59
Java Question

how to use Indexed hint Option Query

I have a collection on which i have a index on a filed named symbol .

I have read the benefeies of using hint on a query which reduces speed of the query

db.collection.find({"symbol" : "RESD"}).hint( { symbol: 1 } )

Could anybody please tell me how can i use Indexed hint Option Query with java , right now this is my code .

BasicDBObject query = new BasicDBObject();
query.put("symbol", symbol);
DBCursor cursor = coll.find(query);


You can try:

DBCursor cursor = coll.find(query).hint(new BasicDBObject("symbol" , 1))