Hello, I am using lucene in my organization. I want to know how can I get distinct values from lucene index. I have tried “GroupingSearch” API but it doesn’t serves the purpose. It will give all documents contains distinct values. I have used below code.
final GroupingSearch groupingSearch = new GroupingSearch(groupField); Sort sort = new Sort(new SortField(groupField, SortField.Type.STRING_VAL, false)); groupingSearch.setSortWithinGroup(sort); Query query = new MatchAllDocsQuery(); TopGroups<BytesRef> topGroups = null; try { topGroups = groupingSearch.search(searcher, query, 0, 10); } catch (final IOException e) { System.out.println("Can't execute group search because of an IOException. "+ e); } Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10