Elasticsearch-dsl-py: There is no connection with alias 'default'

Created on 28 Aug 2017  路  4Comments  路  Source: elastic/elasticsearch-dsl-py

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'."

Most helpful comment

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

All 4 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

abuzakaria picture abuzakaria  路  4Comments

mortada picture mortada  路  3Comments

quasiben picture quasiben  路  4Comments

MauriJHN picture MauriJHN  路  4Comments

vmogilev picture vmogilev  路  4Comments