After looking into it a bit more, it doesn't seem to be possible in Elasticsearch... So I guess we will have a hard time doing it in Lucene too. See https://stackoverflow.com/questions/27776582/aggregation-sorting-pagination-in-elastic-search Maybe the best solution would be to avoid the problem altogether, advising users querying index A that need a DISTINCT on some related entity B's ID to index that entity B instead, and to rely on nested fields for advanced predicates on entity A. |