From 922f777fbbbe912042d307f6643cb684434a0176 Mon Sep 17 00:00:00 2001 From: "Jiangjie.Bai" Date: Wed, 28 Sep 2022 16:10:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E5=AD=98=E5=82=A8es=E5=A4=B1=E6=95=88=E6=97=B6,=20=E4=BC=9A?= =?UTF-8?q?=E8=AF=9D=E3=80=81=E5=91=BD=E4=BB=A4=E8=AE=B0=E5=BD=95=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=88=9B=E5=BB=BA=E5=92=8C=E6=9F=A5=E7=9C=8B=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/terminal/backends/command/es.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/terminal/backends/command/es.py b/apps/terminal/backends/command/es.py index 20602769c..2aa9be1af 100644 --- a/apps/terminal/backends/command/es.py +++ b/apps/terminal/backends/command/es.py @@ -184,9 +184,14 @@ class CommandStore(object): return Command.from_multi_dict(source_data) def count(self, **query): - body = self.get_query_body(**query) - data = self.es.count(index=self.query_index, doc_type=self.doc_type, body=body) - return data["count"] + try: + body = self.get_query_body(**query) + data = self.es.count(index=self.query_index, doc_type=self.doc_type, body=body) + count = data["count"] + except Exception as e: + logger.error('ES count error: {}'.format(e)) + count = 0 + return count def __getattr__(self, item): return getattr(self.es, item)