Hi ,
I am using an ealstic query where I need to find all the running job in last 15 mins.
I captured the job data in a index. I just want to get the latest doc (single doc for each job). I tried to use top_hits but I am getting multiple value for a jobid. Could you pls help me.
Here is my query.
es.search(index='xyz-*',size=10000, body ={"aggs": { "group": { "terms": { "field": "Id.keyword" }, "aggs": { "group_docs": { "top_hits": { "size": 1, "sort": [ { "@timestamp": { "order": "desc" } } ] } } } } }, "query": { "bool": { "must": [ { "match_all": {} }, { "match_phrase": { "clustername": { "query": "abc" } } }, { "match_phrase": { "status.keyword": { "query": "RUNNING" } } },{ "range": { "@timestamp": { "gte": 1563428965639, "lte": 1563429865639, "format": "epoch_millis" } } }] }} })