Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Args:
es_host (str): The Elasticsearch host server
es_user (str): The Elasticsearch username for http auth
es_pass (str): The Elasticsearch password for http auth
"""
es_host = es_host or os.environ.get("MM_ES_HOST")
es_user = es_user or os.environ.get("MM_ES_USERNAME")
es_pass = es_pass or os.environ.get("MM_ES_PASSWORD")
try:
http_auth = (es_user, es_pass) if es_user and es_pass else None
es_client = Elasticsearch(es_host, http_auth=http_auth)
return es_client
except ElasticsearchException:
raise KnowledgeBaseError
except ImproperlyConfigured:
raise KnowledgeBaseError