Field collapsing and documents ordering

Hi,
Field collapsing is very usefull feature but I've faced a results sorting issue.
Let there is a lot of documents with user and date fields.
I need to collapse documents by user field and sort results by date in descending order.

{
  "sort": [
    {
      "date": {
        "order": "desc"
      }
    }
  ],
  "query": {
    "match_all": {}
  },
  "collapse": {
    "field": "users"
  }
}

An additional reqirement is that a document with minimal date in each collapsed group should be used as a hit (ascending document ordering in each group by date).
It is possible via terms/top_hits aggregations where both aggregations can have its own sorting criteria.
Hit selection with 'collapse' feature is based on global sorting criterion and there is no way to pick up other document (with earliest date in this case) that would participate in global sorting.
Paging support via collapsing is a big advantage over term/top_hits, but limited sorting functioality is prohibitive in my case. It would be nice to have a hit selection functionality based on diffetrent sorting order inside each collapsed group.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.