title: Using distinct in a mongo query in java
body: <p>I'm trying to use a distinct query for <code>mongodb</code> in java. looking at this link it says I can just pass in the field name:</p>
  
  <p><a href="https://api.mongodb.org/java/3.0/com/mongodb/DBCollection.html#distinct-java.lang.String-" rel="nofollow">https://api.mongodb.org/java/3.0/com/mongodb/DBCollection.html#distinct-java.lang.String-</a></p>
  
  <p>So I have:</p>
  
  <pre><code>searchResults = playerCollection.distinct("team");
  </code></pre>
  
  <p>But it says it cannot resolve method distinct(<code>java.lang.String</code>)</p>
  
  <p>It seems to think i have to put in another class parameter. But I do not want any subset of the results. I just want all the distinct teams.</p>
  
  <p>Update: How I instantiated the collection:</p>
  
  <pre><code>uri = new MongoClientURI("mongodb://&lt;MongoURI&gt;");
  mongoClient = new MongoClient(uri);
  mongoDB = mongoClient.getDatabase(uri.getDatabase());
  playerCollection =  mongoDB.getCollection("players");
  </code></pre>