diff --git a/sausage/esoperations.py b/sausage/esoperations.py index 0c3f270..82eb6b3 100644 --- a/sausage/esoperations.py +++ b/sausage/esoperations.py @@ -1,18 +1,23 @@ # © All rights reserved. ECOLE POLYTECHNIQUE FEDERALE DE LAUSANNE, # Switzerland # SCITAS - Scientific IT and Application Support, 2021 # See the LICENSE.txt file for more details. -from elasticsearch import Elasticsearch +import importlib +for mname in "elasticsearch elasticsearch6": + es_spec = importlib.util.find_spec(mname) + if es_spec is not None: + from mname import Elasticsearch + break class ESOp: def __init__(self, server): self.server = Elasticsearch([server]) def esget(self, index, doc): try: response = self.server.search(index=index, body=doc) return response except BaseException: return ""