python - 在Elasticsearch上获得连接错误

标签 python elasticsearch

我正在与elasticsearch建立连接,但无法理解为什么出现此错误。每当我输入python解释器时都会发生这种情况。

>>> from elasticsearch import Elasticsearch
>>> es = Elasticsearch('http://localhost:9200')
>>> es.index(index='my_index', id=1, body={'text': 'this is a test'})

elasticsearch.exceptions.ConnectionError:ConnectionError

最佳答案

试试这个:
es = Elasticsearch([{'host': 'localhost', 'port': 9200}])

关于python - 在Elasticsearch上获得连接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60479394/

相关文章:

Python Mechanize Browser.links() - 奇怪的行为

python - 如何防止在单元测试python中截断字符串

Python,巨大的迭代性能问题

python - ModelChoiceField 不显示外键选择

c# - 在Elasticsearch NEST中的主要多重匹配查询之后应用不同的过滤器

plugins - kibana-4.3如何开发插件

apache-spark - 在不安全模式下的Elasticsearch Pyspark连接

nosql - 如何在 Elastic Search 上传输 Cassandra 数据并建立索引?

elasticsearch - Elastic Search重新索引套接字超时后,我可以连续重新索引该过程吗

Python Pandas : fill a dataframe row by row