rest - 如何在具有弹性云的python上使用elasticsearch库?

标签 rest elasticsearch

新手要休息的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/

相关文章:

elasticsearch - 为 not null 和 not empty (""创建 Elasticsearch curl 查询)

jquery - Sharepoint 2013 Rest API : create to multivalue column

elasticsearch - Elasticsearch 按筛选器按多个字段分组

java - 使用 Jersey 通过 REST 获取 CSRF token 并在登录中使用它

java - Dropwizard Rest API 端点操作

java - Java TransportClient 的结果与 REST/CURL 的结果不同

curl - curl中的PostgreSQL查询

elasticsearch - logstash示例插件不起作用

javascript - 将数组与 javascript 调用一起发送到 java -rest 中的 Driver 类

jquery - 动态地将三张卡片水平对齐一行