Find earliest document per id

I have an index in Elasticsearch which contains multiple documents per ID.
For the 50 most recent IDs, I'd like to select the first document based on the timestamp.
Is such a thing possible with Elasticsearch?

For example, several documents with the fields ID and Timestamp:
ID, Timestamp
1, 16:00
1, 16:05
1, 16:10
2, 17:00
2, 17:10
2, 17:20

Cheers,
Nils

You can use field collapsing for that. You'd sort on the timestamp, and collapse on the ID.

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