我正在尝试 ping 我的 Elasticsearch 实例(通过 Bonsai 和 Heroku 插件部署)。我遵循了他们的指导方针并尝试在我的计算机上执行以下代码:
from elasticsearch import Elasticsearch
from settings import BONSAI_URL
import re, logging
# Log transport details (optional):
logging.basicConfig(level=logging.INFO)
# Parse the auth and host from env:
bonsai = BONSAI_URL
print(bonsai)
auth = re.search('https\:\/\/(.*)\@', bonsai).group(1).split(':')
host = bonsai.replace('https://%s:%s@' % (auth[0], auth[1]), '')
# Connect to cluster over SSL using auth for best security:
es_header = [{
'host': host,
'port': 443,
'use_ssl': True,
'http_auth': (auth[0],auth[1])
}]
# Instantiate the new Elasticsearch connection:
es = Elasticsearch(es_header)
# Verify that Python can talk to Bonsai (optional):
es.ping()
我收到以下错误消息:
elasticsearch.exceptions.ImproperlyConfigured: Root certificates are missing for certificate validation. Either pass them in using the ca_certs parameter or install certifi to use it automatically.
我相信这个错误是因为我没有 https 证书,所以我使用 HTTP,通过删除s
URL 和正则表达式中的 并将其切换use_ssl
为 False 但我收到以下错误:
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))
如何将计算机中的数据插入 Heroku 上的 elasticsearch?