title: Remove duplicate values from the result of MongoDB objects
body: <p>How to remove duplicate values from the result of MongoDB objects?</p>
  
  <p>I have some records in my mongodb as follows</p>
  
  <pre><code>{"Filename":"PHP Book.pdf","Author":"John" ,"Description":"This is my PHP Book"} 
  {"Filename":"Java Book.html" ,"Author":"Paul" ,"Description":"This is my JAVA Book"}
  {"Filename":".NET Book.doc" ,"Author":"James" ,"Description":"This is my .NET Book"}
  </code></pre>
  
  <p>below is my code to search Filename and Description fields which contains "Java" word and displaying their filenames.</p>
  
  <pre><code>Mongo m = new Mongo("10.0.0.26", 27017) ;
  DB db = m.getDB("soft") ;
  DBCollection col = db.getCollection("poc") ;
  
  BasicDBObject query = new BasicDBObject();
  BasicDBObject query1 = new BasicDBObject();
  
  String KeyWord="JAVA";
  query.put("Filename",  java.util.regex.Pattern.compile(KeyWord));
  query1.put("Content",  java.util.regex.Pattern.compile(KeyWord));
  DBCursor cursor = col.find(query) ;
  DBCursor cursor1 = col.find(query1) ;
      while (cursor.hasNext()) {
          DBObject o = cursor.next();
          System.out.println("File name contains JAVA:"+o.get("Filename"));
          }
      while (cursor1.hasNext()) {
          DBObject ob = cursor1.next();
          System.out.println("File name whose content contains JAVA:"+ob.get("Filename"));
              }
  </code></pre>
  
  <p>I am getting the following output:</p>
  
  <pre><code>File Name Contains JAVA:Java Book.html
  File Name  whose content Contains JAVA:Java Book.html
  </code></pre>
  
  <p>I am getting same file name from both filename and content queries.I want to remove the duplicate values.Please suggest me.</p>
  
  <p>thanks</p>