The goal is to create an Elasticsearch index with only the most recent documents in groups of related documents , in order to keep track of the current state of some control counters and states.
I created a simple Elasticsearch aggregation request :
{ "size": 0, "aggs": { "group_by_monitor": { "terms": { "field": "monitor_name" }, "aggs": { "get_latest": { "top_hits": { "size": 1, "sort": [ { "timestamp": { "order": "desc" } } ] } } } } } }
He groups related documents into buckets and selects the most recent document for each bucket.
Here are the different ideas that I had to fulfill:
Is there a fairly sophisticated way to accomplish this?
source share