Here is the config:
searchurl = '192.168.0.1'
client = Elasticsearch(['http://elasticuser:passwd@' + searchurl + ':9200'])
body = {
"query": {
"bool": {
"must": [
{
"query_string": {
"default_field": "title.cn",
"analyzer": "ik_smart",
"query": "hilton"
}
}
],
}
}
}
s = Search(using=client, index='flyertea', doc_type='thread')\
.from_dict(body)
File "Search.py", line 26, in
print (s.execute())
File "/usr/local/lib/python3.6/site-packages/elasticsearch_dsl/search.py", line 598, in execute
es = connections.get_connection(self._using)
File "/usr/local/lib/python3.6/site-packages/elasticsearch_dsl/connections.py", line 94, in get_connection
raise KeyError('There is no connection with alias %r.' % alias)
KeyError: "There is no connection with alias 'default'."
from_dict is a class method that constructs a new Search object (which doesn't have your settings), if you want to use the current one with your settings use update_from_dict.
You can also use the connections object in the connections module of elasticsearch_dsl to configure the connection globally.
Hope this helps
thanks
Arrgggggg..... I actually knew this one but forgot about it.
i am confused
Most helpful comment
from_dictis a class method that constructs a newSearchobject (which doesn't have your settings), if you want to use the current one with your settings useupdate_from_dict.You can also use the
connectionsobject in theconnectionsmodule ofelasticsearch_dslto configure the connection globally.Hope this helps