I am using elastic search 2.3 version in my java project. I want to execute the following sql query for elastic search -
select fileName from (select distinct fileName from explore_object_metadata order by original_size desc)where rownum <=10
For this I try -
client.prepareSearch()
.setIndices()
.setTypes(getType())
.addSort(fieldSort("sourceSize").order(DESC))
.setScroll(new TimeValue(ES_TIMEOUT_MS))
.setSize(10);
But it gives me 10 result in descending order with repeated fileName multiple times. What can I do to get top 10 records with unique filename and sorted in descending order by their size in elastic search.