From 694dbc31c43207dee06c4977df08c7763b1317fe Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Sun, 25 Jul 2021 14:40:49 +0300 Subject: [PATCH] Fix incorrect ES query (merge issue) --- apiserver/bll/event/event_bll.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/apiserver/bll/event/event_bll.py b/apiserver/bll/event/event_bll.py index 2a6af59..ff4d2c1 100644 --- a/apiserver/bll/event/event_bll.py +++ b/apiserver/bll/event/event_bll.py @@ -931,12 +931,17 @@ class EventBLL(object): es_req: dict = { "size": 0, "aggs": { - "iters": { - "terms": { - "field": "iter", - "size": iters, - "order": {"_key": "desc"}, - } + "tasks": { + "terms": {"field": "task"}, + "aggs": { + "iters": { + "terms": { + "field": "iter", + "size": iters, + "order": {"_key": "desc"}, + } + } + }, } }, "query": {"bool": {"must": [{"terms": {"task": task_ids}}]}}, @@ -944,7 +949,7 @@ class EventBLL(object): with translate_errors_context(), TimingContext("es", "task_last_iter"): es_res = search_company_events( - self.es, company_id=company_id, event_type=event_type, body=es_req + self.es, company_id=company_id, event_type=event_type, body=es_req, ) if "aggregations" not in es_res: