From 8a413563beb8fc51fbf1e54df34994d697ec18c4 Mon Sep 17 00:00:00 2001 From: feng626 <1304903146@qq.com> Date: Tue, 26 Oct 2021 16:23:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=91=BD=E4=BB=A4=E8=AE=B0=E5=BD=95-?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E9=80=89=E6=8B=A9=E9=A1=B9=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=EF=BC=9A=E5=8D=B4=E5=AF=BC=E5=87=BA=E4=BA=86=E6=89=80=E6=9C=89?= =?UTF-8?q?=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/terminal/backends/command/es.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/apps/terminal/backends/command/es.py b/apps/terminal/backends/command/es.py index 678698ff6..7863dbbfb 100644 --- a/apps/terminal/backends/command/es.py +++ b/apps/terminal/backends/command/es.py @@ -131,10 +131,13 @@ class CommandStore(): index=self.index, doc_type=self.doc_type, body=body, from_=from_, size=size, sort=sort ) + source_data = [] + for item in data['hits']['hits']: + if item: + item['_source'].update({'id': item['_id']}) + source_data.append(item['_source']) - return AbstractSessionCommand.from_multi_dict( - [item['_source'] for item in data['hits']['hits'] if item] - ) + return AbstractSessionCommand.from_multi_dict(source_data) def count(self, **query): body = self.get_query_body(**query) @@ -160,11 +163,16 @@ class CommandStore(): new_kwargs[k] = str(v) if isinstance(v, UUID) else v kwargs = new_kwargs + index_in_field = 'id__in' exact_fields = self.exact_fields match_fields = self.match_fields match = {} exact = {} + index = {} + + if index_in_field in kwargs: + index['values'] = kwargs[index_in_field] for k, v in kwargs.items(): if k in exact_fields: @@ -221,6 +229,10 @@ class CommandStore(): 'timestamp': timestamp_range } } + ] + [ + { + 'ids': {k: v} + } for k, v in index.items() ] } },