无法从elasticsearch导入名称RequestsHttpConnection

cfh9epnr  于 2023-04-11  发布在  ElasticSearch
关注(0)|答案(2)|浏览(318)

RequestsHttpConnection工作正常,直到我不得不重新安装Anaconda,现在使用Python3.9. Form只是试图导入RequestsHttpConnection。我得到了下面的错误。
from elasticsearch import Elasticsearch, RequestsHttpConnection
错误:无法从“elasticsearch”(\Anaconda 3\lib\site-packages\elasticsearch_init_.py)导入名称“RequestsHttpConnection”
我安装了elasticsearch-8.0.0,也安装了请求。
任何帮助都很感激。

2w2cym1i

2w2cym1i1#

这个东西在版本8和更高版本中被弃用。

pip uninstall elasticsearch
pip install elasticsearch==7.13.4
7kjnsjlb

7kjnsjlb2#

Got it working in ES 8.3.0 with SSL connection and Python ES client 7.13.4
    from elasticsearch import RequestsHttpConnection  
    es = Elasticsearch(
        ['localhost'],
        http_auth=('elastic', 'put-it-here'),
        scheme="https",
        port=9200,
        ssl_context=context,
        use_ssl=True,
        verify_certs=False,
        connection_class=RequestsHttpConnection,
    )

    print(es.info())
    res = es.search(index="index-name", body={"query": {"match_all": {}}})

    print(res['hits']['total'])

相关问题