新手要休息的API和 flex 云在这里尝试将我的json文件发布到elasticsearch中,这样我就可以在kibana中建立索引并查看它。因此,我在网上阅读了elasticsearch库,基本上遵循了letter.的示例,但是尝试运行该库时遇到连接错误。现在,该教程指的是本地 flex 而不是云,因此我猜想云的身份验证是不同的,我应该以某种方式添加用户和密码吗?有人可以帮我吗?
请注意,当我尝试使用get时,我实际上得到了代码200,因此通信应该没问题
es = Elasticsearch([{'host': 'https:/cloudhosturl', 'port': 9243}])
for i,line in enumerate(emails):
for match in re.finditer(from_pat, line):
ioc.append(match.group(1))
es.index(index='senders', doc_type='addresses', id=k, body=json.dumps(match.group(1)))
elasticsearch.exceptions.ConnectionError: ConnectionError(: Failed to establish a new connection: [Errno 11001] getaddrinfo failed) caused by: NewConnectionError(: Failed to establish a new connection: [Errno 11001] getaddrinfo failed)
最佳答案
我正在使用https://elasticsearch-py.readthedocs.io/en/master/中的代码段,它适用于 flex 云群集。
它需要pip install elasticsearch
例:
es = Elasticsearch(
['https:/cloudhosturl'],
http_auth=('USERNAME', 'PASSWORD'),
scheme="https", port=443,)
关于rest - 如何在具有弹性云的python上使用elasticsearch库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59741699/