From 574bd56c903678415e16db97af8d3932b6021c16 Mon Sep 17 00:00:00 2001 From: Wei Mingzhi Date: Mon, 15 Apr 2024 11:52:24 +0800 Subject: [PATCH] Allows `elasticsearch7' package to be used instead of `elasticsearch'. --- .../core/components/retriever/bes/bes_retriever.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/appbuilder/core/components/retriever/bes/bes_retriever.py b/appbuilder/core/components/retriever/bes/bes_retriever.py index 06b83036..abfc4b7d 100644 --- a/appbuilder/core/components/retriever/bes/bes_retriever.py +++ b/appbuilder/core/components/retriever/bes/bes_retriever.py @@ -62,12 +62,17 @@ def helpers(self): def _lazy_import_es(self): if self._es is None or self._helpers is None: try: - from elasticsearch import Elasticsearch, helpers + from elasticsearch7 import Elasticsearch, helpers self._es = Elasticsearch self._helpers = helpers except ImportError: - raise ImportError("Elasticsearch module is not installed. " - "Please install it using 'pip install elasticsearch==7.11.0'.") + try: + from elasticsearch import Elasticsearch, helpers + self._es = Elasticsearch + self._helpers = helpers + except ImportError: + raise ImportError("Elasticsearch module is not installed. " + "Please install it using 'pip install elasticsearch7==7.11.0'.") @staticmethod def generate_id(length=16):