title: How to get distinct value from Lucene Field
body: <p>I am trying to make a search from Lucene index. I have created an index using StandardAnalyzer 
  I have the data to be indexed like following</p>
  
  <p>course 
  BCA
  MCA
  BCA
  BCA
  MCA</p>
  
  <p>When i search on course ="BCA" it returns me 3 times BCA but i want it should give the distinct values ie only once </p>
  
  <p>I am using the following code</p>
  
  <pre><code>     try {
           File indexDir = new File("D:\\indexdirectory\\");
           Directory directory = FSDirectory.open(indexDir);
           IndexSearcher searcher = new IndexSearcher(directory, true);
           QueryParser parser1;
           parser1= new QueryParser(Version.LUCENE_36, "course", new StandardAnalyzer(Version.LUCENE_36));
           Query query = parser1.parse("BCA");
           int maxhits = 5000;
           TopDocs topDocs = searcher.search(query, maxhits);
           ScoreDoc[] hits = topDocs.scoreDocs;
           int len = hits.length;
           int docId;
           Document d;
               for(int j=0;j&lt;len;j++) {
                   docId = hits[j].doc;
                   d = searcher.doc(docId);                
                   String c = d.get("course"); 
                   System.out.println("Course = "+c);
               } 
  
       }catch(Exception e) {
           System.out.println("Exception occured"+e);
       }
  </code></pre>
  
  <p>it returns BCA 3 times not only once as expected.</p>