gpt4 book ai didi

python-2.7 - 建立新连接失败 : [Errno 111] Connection refused(elasticsearch)

转载 作者:行者123 更新时间:2023-11-29 02:46:04 24 4
gpt4 key购买 nike

我已经使用此命令安装了 elasticsearch:pip install elasticsearch安装后我执行了以下命令:

>>> from datetime import datetime
>>> from elasticsearch import Elasticsearch
# by default we connect to localhost:9200
>>> es = Elasticsearch()
# create an index in elasticsearch, ignore status code 400 (index already exists)
# but when I run this instruction:
>>> es.indices.create(index='my-index', ignore=400) // HERE IS THE PROBLEM

我收到这个错误:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "elasticsearch/client/utils.py", line 69, in _wrapped
return func(*args, params=params, **kwargs)
File "elasticsearch/client/indices.py", line 110, in create
params=params, body=body)
File "elasticsearch/transport.py", line 327, in perform_request
status, headers, data = connection.perform_request(\
method, url, params, body, ignore=ignore, timeout=timeout)
File "elasticsearch/connection/http_urllib3.py", line 105, in perform_request
raise ConnectionError('N/A', str(e), e)
elasticsearch.exceptions.ConnectionError:
ConnectionError(<urllib3.connection.HTTPConnection object at 0xM3M>:
Failed to establish a new connection: [Errno 111] Connection refused) caused by:
NewConnectionError(<urllib3.connection.HTTPConnection object at 0xM3M>:
Failed to establish a new connection: [Errno 111] Connection refused)

最佳答案

您安装的是一个 Python 客户端,用于您的 Python 脚本和现有 Elasticsearch 集群之间的通信。

如您的评论所述,在 page 的顶部你开始阅读,它说:

Official low-level client for Elasticsearch. Its goal is to provide common ground for all Elasticsearch-related code in Python; because of this it tries to be opinion-free and very extendable.

您可以为客户端配置运行集群的主机和端口,并连接到它并在该集群上执行命令。

在您的代码中,您将客户端配置为使用默认设置,该默认设置假定集群在具有默认 Elasticsearch 端口 9200localhost 上运行。

您需要Install Elasticsearch on a machine ,配置并运行它,然后您就可以将您的客户端连接到集群并与之通信。

关于python-2.7 - 建立新连接失败 : [Errno 111] Connection refused(elasticsearch),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39447617/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com