How to use the elasticsearch5.ImproperlyConfigured function in elasticsearch5

To help you get started, we’ve selected a few elasticsearch5 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cisco / mindmeld / mindmeld / components / _elasticsearch_helpers.py View on Github external
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