【发布时间】:2018-03-10 09:02:22
【问题描述】:
我想使用来自 aws 的弹性搜索来满足我的使用需求。以下代码在我的本地弹性搜索中运行良好,但在尝试连接到 aws elasticsearch 服务时总是出错。我正在使用 python 2.7、django 1.10 和弹性搜索 5.1.1。 以下是错误
ConnectionError(HTTPSConnectionPool(host='https', port=443): url 超出最大重试次数://search-test-abc-jlpfzhi64qcrhhqxycov5rzgcq.ap-south-1.es.amazonaws.com/:443/test-index/ tweet/1 (Caused by NewConnectionError('另外,这是我正在使用的代码
host = AWS_ELASTIC_SEARCH_URL
awsauth = AWS4Auth(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_ELASTIC_SEARCH_REGION, 'es')
es = Elasticsearch(
hosts=[{'host': host, 'port': 443}],
http_auth=awsauth,
use_ssl=True,
verify_certs=True,
connection_class=elasticsearch.RequestsHttpConnection
)
doc = {
'author': 'kimchy',
'text': 'Elasticsearch: cool. bonsai cool.',
'timestamp': datetime.now(),
}
res = es.index(index="test-index", doc_type='tweet', id=1, body=doc)
最后一行出现错误。我还可以完全访问弹性搜索网址。
【问题讨论】:
-
听起来像 python 2.7 错误。解决方案见stackoverflow.com/questions/29099404/…
-
@sramalingam24 感谢您的评论……我犯了一个愚蠢的错误……终于弄明白了。
标签: django python-2.7 amazon-web-services elasticsearch django-haystack