Preethi Jain Preethi Jain - 1 year ago 130
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);

Answer Source

You can try:

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download