Elasticsearch Python API

0 投票
1 回答
2030 浏览
提问于 2025-04-18 11:28

我正在尝试使用Python的API "pyes" 来操作elasticsearch,但第一次使用时遇到了问题。我运行了以下代码:

import pyes
conn = pyes.ES('127.0.0.1:9200')
conn.indices.create_index("test-index")

但是出现了以下错误:

No handlers could be found for logger "pyes"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/easd/data01/binmaham/python/lib/python2.7/site-packages/pyes-0.99.2-py2.7.egg/pyes/managers.py", line 155, in create_index
    return self.conn._send_request('PUT', index, settings)
  File "/easd/data01/binmaham/python/lib/python2.7/site-packages/pyes-0.99.2-py2.7.egg/pyes/es.py", line 441, in _send_request
    response = self.connection.execute(request)
  File "/easd/data01/binmaham/python/lib/python2.7/site-packages/pyes-0.99.2-py2.7.egg/pyes/connection_http.py", line 109, in execute
    self._local.server = server = self._get_server()
  File "/easd/data01/binmaham/python/lib/python2.7/site-packages/pyes-0.99.2-py2.7.egg/pyes/connection_http.py", line 145, in _get_server
    raise NoServerAvailable(ex)
pyes.exceptions.NoServerAvailable: list index out of range

1 个回答

2

正如 @furas 和你的错误信息所提示的,要启动你的 ElasticSearch 服务器,你可以运行 sudo /etc/init.d/elasticsearch start你可以在这里查看详细信息

撰写回答