title: How to provide a hint in java-mongodb driver for find
body: <p>I am trying to tune some queries I have on my mongodb from a java client. Inspecting the active running operations for the current database I noticed the fact that some queries having something like:</p>
  
  <pre><code>db.getCollection("buba-collection").find({ _id: { $in: [ "aaaa", "bbb", "cccc"  } });
  </code></pre>
  
  <p>they are not touching any index. It is true, I may have up to 1k elements in <code>$in</code> clause, but only 15-20% of the queries are not touching the index. The mongo-cluster is sharded (hash, by <code>_id</code>) and I am looking to get elements via <code>_id_</code> index or by the sharded index. They should provide the same performance - I guess. The expected result should be:</p>
  
  <pre><code>db.getCollection("buba-collection").find({ _id: { $in: [ "aaaa", "bbb", "cccc"  } }).hint("sharded_index");
  </code></pre>
  
  <p>So, what I tried:</p>
  
  <pre><code>MongoCollection&lt;Document&gt; source = getCollectionHere();
  BasicDBList docIds = new BasicDBList();
  docIds.addAll(ids);
  BasicDBObject inClause = new BasicDBObject("$in", docIds);
  BasicDBObject query = new BasicDBObject("_id", inClause);
  return source.find(query).batchSize(1000).hint(new BasicDBObject("_id", 1)).iterator();
  </code></pre>
  
  <p>It seems like the only possible way is to provide the indexed column I am after. However, in mongodb docs they mention that you can also specify the index name. </p>
  
  <p>My question is: can I do the same thing in Java?</p>
  
  <pre><code>Mongodb version: 4.0.3;
  Java driver version: 3.10.1;
  Java: 1.8.200;
  </code></pre>