logo
Browse Source

Update with es

main
shiyu22 2 years ago
parent
commit
ffd44dc11b
  1. 6
      es_search.py

6
es_search.py

@ -25,9 +25,9 @@ class ESSearch(PyOperator):
super().__init__()
try:
self.client = Elasticsearch(
f'https://{host}:{port}',
f'http://{host}:{port}' if not ca_certs else f'https://{host}:{port}',
ca_certs=ca_certs,
basic_auth=(user, password))
basic_auth=(user, password) if user and password else None)
logger.info('Successfully connected to ElasticSearch client.')
except Exception as e:
logger.error('Failed to connect ElasticSearch client:\n', e)
@ -35,7 +35,7 @@ class ESSearch(PyOperator):
def __call__(self, index_name: str, query: dict = {'match_all': {}}, enable: bool=True):
if not enable:
return None
return ''
resp = self.client.search(index=index_name, query=query)
return resp

Loading…
Cancel
Save