python - Python 连接 AWS ElasticSearch 域并上传、检索数据
问题描述
我已经在 AWS Elasticsearch Service 中设置了 elasticsearch 域。它具有类似“ https://search-testelasticseach-xxxxxxxxxxxxxxxxxxx.us-east-2.es.amazonaws.com ”的端点。在该弹性搜索域中添加策略后,我正在尝试使用 IAM 用户连接 AWS Elasticsearch 域端点。
错误说
"Max retries exceeded with url: //search-testelasticseach-XXXXXXXXXXXXXXX.us-east-2.es.amazonaws.com:443/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x105111d68>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known'))) caused by: ConnectionError(HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //search-testelasticseach-pkpbravqd4djbi3kjtihsra5ma.us-east-2.es.amazonaws.com:443/ (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x105111d68>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known')))"
代码片段:
from elasticsearch import Elasticsearch, RequestsHttpConnection
from requests_aws4auth import AWS4Auth
YOUR_ACCESS_KEY = "XXX"
YOUR_SECRET_KEY = "XXXX"
REGION = "us-east-2"
host = 'https://search-testelasticseach-XXX.us-east-2.es.amazonaws.com'
awsauth = AWS4Auth(YOUR_ACCESS_KEY, YOUR_SECRET_KEY, REGION, 'es')
es = Elasticsearch(
hosts=[{'host': host, 'port': 443}],
http_auth=awsauth,
use_ssl=True,
verify_certs=True,
connection_class=RequestsHttpConnection
)
print(es.info())
解决方案
推荐阅读
- javascript - 使用javascript验证表单中的选择时出错
- rust - 如何测试对象的其他特征函数
- html - Outlook 桌面的徽标大小调整
- powershell - [System.Web.Security.Membership]::GeneratePassword() - 找不到类型
- c# - OnItemDataBound 将列表视图中的链接按钮注册到更新面板脚本管理器,但是,它们仅在第一次单击时起作用
- java - 具有相同存储库和实体的多个数据源
- database - 如何在 GDPR 下将用户名存储在数据库中?
- c - 比较频繁输入数据和存储 MAX 和 MIN 值的快速方法
- css - 即使删除了 margin 属性,元素仍然有边距
- jquery - Jquery Datepicker 输入