title: Get random documents/records from MongoDB with Java
body: <p>Below I have a bit of Java code to get all records/documents from a collection</p>
  
  <pre><code>    DBCollection collection = database.getCollection("collection");
  
      BasicDBObject select = new BasicDBObject();
      select.put("title", 1);
      select.put("name", 1);
  
      String random = JSON.serialize(collection.find(select));
  </code></pre>
  
  <p>Now I would like to get say 10 documents random from the collection.</p>
  
  <p>How would I do this? Is this possible? </p>
  
  <p>I have found many questions of others but not a real solution. I have about 1500 documents in the collection. Speed is not very important.</p>
  
  <p>Thanks for any help!</p>