The Elasticsearch connection used internally by ElasticUtils supports two ways of configuration:
By string and by dict. Usually using string method is good enough, although some connections require passing a dict (for exampe with auth). At the moment, when you pass a dict, ElasticUtils throws TypeError: unhashable type: 'dict' because it tries to cache the connection.
A current workaround for now is to wrap the dict in tuple, so that the hash function succeeds. For example:
def es_url_to_dict(url):
parse = urlparse(url)
port = parse.port if parse.port else (80 if parse.scheme == 'http' else 443)
use_ssl = port is 443
host = {'host': parse.hostname,
'port': port,
'use_ssl': use_ssl,
'http_auth': '%s:%s' % (parse.username, parse.password)}
return tuple(sorted(host.items()))
ES_URLS = [es_url_to_dict(os.environ.get('ES_URL', 'http://localhost:9200'))]
With this you can configure urls like https://myuser:mypass@myhost
The Elasticsearch connection used internally by ElasticUtils supports two ways of configuration:
By string and by dict. Usually using string method is good enough, although some connections require passing a dict (for exampe with auth). At the moment, when you pass a dict, ElasticUtils throws TypeError: unhashable type: 'dict' because it tries to cache the connection.
A current workaround for now is to wrap the dict in tuple, so that the hash function succeeds. For example:
With this you can configure urls like
https://myuser:mypass@myhost