From 32ec48ac14b206f82d7f6e8b68a67e0a150f607a Mon Sep 17 00:00:00 2001 From: wangruidong <940853815@qq.com> Date: Fri, 16 Aug 2024 15:39:28 +0800 Subject: [PATCH] perf: Improve performance by optimizing ES index creation --- apps/common/plugins/es.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/common/plugins/es.py b/apps/common/plugins/es.py index 0b1bf702b..c4b2d0921 100644 --- a/apps/common/plugins/es.py +++ b/apps/common/plugins/es.py @@ -190,7 +190,8 @@ class ES(object): mappings['aliases'] = { self.query_index: {} } - + if self.es.indices.exists(index=self.index): + return try: self.es.indices.create(index=self.index, body=mappings) except (RequestError, BadRequestError) as e: