如何修复索引字典时的请求超时



我正在尝试在弹性中索引数据,但出现超时错误。

所以我尝试更改端口,并尝试增加超时。我也尝试将数据转换为 json。

Data 是 Python 字典:


from elasticsearch import Elasticsearch
es = Elasticsearch([{'host': 'localhost', 'port': 9200}])

def index_profile(data):
es.index(index='prof', id=data["id"], doc_type='people', body=data, request_timeout=30)

这是我的弹性配置文件的网络和发现部分:

# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: localhost
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.seed_hosts: ["localhost", "[::1]"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]
#
# For more information, consult the discovery and cluster formation module documentation.
#

最后我收到此错误: elasticsearch.exceptions.ConnectionTimeout: ConnectionTimeout 由 - ReadTimeoutError(HTTPConnectionPool(host='localhost', port=9200(: 读取超时。(读取超时 = 30(( 这是在弹性日志中: 此节点以前未加入自举

如果它对任何人有帮助,我想我需要将此行添加到我的 .yml 文件中

cluster.initial_master_nodes: ["node-1"]

最新更新