在 aws 中的弹性搜索中建立索引时出现连接错误

乌特卡什·斯里瓦斯塔夫

我想使用 aws 的弹性搜索来满足我的需求。以下代码在我的本地弹性搜索中完全正常,但在尝试连接到 aws elasticsearch 服务时总是出错。我正在使用 python 2.7、django 1.10 和弹性搜索 5.1.1。以下是错误

ConnectionError(HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //search-test-abc-jlpfzhi64qcrhhqxycov5rzgcq.ap-south-1.es.amazonaws.com/:443/test-index/ tweet/1 (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f1e2e5e2090>: Failed to build a new connection: [Errno -2] Name or service not known',))) 引起: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('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f1e2e5e2090>: 建立新连接失败:[Errno -2] 名称或服务未知',)))

另外,这是我正在使用的代码

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)

它在最后一行给出错误。此外,我已经完全访问了弹性搜索 url。

乌特卡什·斯里瓦斯塔夫

我终于弄明白了。就我而言,我将主机 url 写为“ https://example.com/ ”,但它应该仅作为“example.com”给出。花了很多时间才把这件事记在我的脑海里。以下是我使用 python 2.7 和 django 1.9 连接到 aws ElasticSearch (5.1) 的工作代码。

def bulk_indexing():

     host = 'example.com'  #not https://example.com"
     awsauth = AWS4Auth('access key', 'secret', region, 'es')
     es = Elasticsearch(
         hosts=[{'host': host, 'port': 443}],
         http_auth=awsauth,
         use_ssl=True,
         verify_certs=True,
         connection_class=RequestsHttpConnection
     )
     payload = {'abc' : 'def'}
     es.index('abc-index', 'doc', payload)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

无法在AWS实例中运行弹性搜索

我只想获取在AWS弹性搜索中创建的,没有JSON键的索引的内容

为什么弹性搜索在 AWS Appsync 中不起作用

在Python中建立引擎连接的AWS Wrangler错误,必须指定一个区域?

从Windows 7使用时在与AWS连接时出现错误

在AWS中连接DAX时出错

在弹性搜索中删除索引时出错

在弹性搜索中创建索引时出错

CodeCommit错误弹性Beanstalk(AWS)

在AWS上建立MySQL连接

NodeJS中的AWS RDS SSL中的连接错误

尝试使用Codebuild buildspec中的Shell脚本登录AWS跨账户时出现codebuild错误

在AWS Secret Manager中配置凭证轮换时出现权限错误

运行任务时出现AWS ECS错误:在集群中未找到容器实例

尝试通过python中的AWS CDK创建预算时出现jsii错误

与RDS建立数据库连接错误AWS Elastic Beanstalk

登录时出现 AWS Cognito 未知错误

AWS Glue 中的 AWS 区域

如何从Kafka连接在弹性搜索中创建多个索引

弹性搜索 knn 索引(aws \ opendistro)是否支持稀疏向量索引?

使用AWS开发工具包从AWS Elastic Search获取索引时出现403禁止错误

AWS Lambda 中的 Python 出现意外的缩进错误

从php中的spefic ip连接AWS RDS(mysql):超时错误

网络错误:AWS EC2 实例中的连接被拒绝

每个aws弹性域的索引数

连接到AWS IoT时出现警报失败,错误= 42

尝试连接到启用了IAM的AWS Neptune时出现400错误的请求

AWS识别投票中的错误

AWS Lex 中的超时错误