Sort with dedupe?

(James) #1

I'd like to return a user-defined number of hits ordered by date (desc) and deduped.

If I don't dedupe, my query works fine. However, when I use the aggregator with top-hits subaggregation my resulting buckets are NOT a deduped version of my results hits. Can someone tell me what I'm doing wrong (or the best way to do this)?

SearchRequestBuilder srb = client.prepareSearch()
   .setScroll(new TimeValue(60000))
    .addSort("orderDTS", SortOrder.DESC)

(system) #2