我在ElasticSearch中的第一次部署的主机名是什么

n7taea2i  于 6个月前  发布在  ElasticSearch
关注(0)|答案(1)|浏览(61)

我正在使用Python中的ElasticSearch(elasticsearch==7.0.2)客户端

from elasticsearch import Elasticsearch

client = Elasticsearch({
  "host": "https://my-first-deployment.es.southamerica-east1.gcp.elastic-cloud.com", 
  "port": 9200
})

字符串
我从ElasticSearch中的第一个部署中获取主机名,复制端点:


的数据
但好像不管用

socket.gaierror: [Errno -3] Temporary failure in name resolution


我错过了什么?
编辑:我不知道它应该是什么端口,也不知道在哪里检查它。我假设它是9200,因为它是本地运行时的默认端口。

t30tvxxf

t30tvxxf1#

我很确定你的端口是不正确的,你可能应该从主机名中删除https://,把它放在一个数组中,并以某种方式表明它应该使用ssl。我认为以这种格式使用整个端点可能会更容易:

client = Elasticsearch(["https://my-first-deployment.es.southamerica-east1.gcp.elastic-cloud.com:12345"],
    http_auth=("elastic", "<password>"),
)

字符串
或者,您可以复制集群ID并像这样使用它:

es = Elasticsearch(
    cloud_id="cluster-1:dXMa5Fx...",
    http_auth=("elastic", "<password>"),
)


注意:我假设你的用户名是elastic
另外,你的部署版本是什么?如果是8.x,你可能应该切换到相应的python客户端版本。

相关问题