当前位置:   article > 正文

python执行elasticsearch异常【已解决】_deprecationwarning: passing transport options in t

deprecationwarning: passing transport options in the api method is deprecate

网站已上线 ,不妨来看看留个言 : http://javapub.net.cn/

文章目录

异常

异常信息

$ python my.py 
my.py:5: DeprecationWarning: Passing transport options in the API method is deprecated. Use 'Elasticsearch.options()' instead.
  es.indices.create(index='test-index', ignore=400)
Traceback (most recent call last):
  File "my.py", line 5, in <module>
    es.indices.create(index='test-index', ignore=400)
  File "C:\Users\EDY\miniconda3\lib\site-packages\elasticsearch\_sync\client\utils.py", line 404, in wrapped
    return api(*args, **kwargs)
  File "C:\Users\EDY\miniconda3\lib\site-packages\elasticsearch\_sync\client\indices.py", line 510, in create
    "PUT", __path, params=__query, headers=__headers, body=__body
  File "C:\Users\EDY\miniconda3\lib\site-packages\elasticsearch\_sync\client\_base.py", line 391, in perform_request
    method, path, params=params, headers=headers, body=body
  File "C:\Users\EDY\miniconda3\lib\site-packages\elasticsearch\_sync\client\_base.py", line 338, in perform_request
    body=resp_body,
elasticsearch.UnsupportedProductError: The client noticed that the server is not Elasticsearch and we do not support this unknown product

  File "C:\Users\EDY\miniconda3\lib\site-packages\elasticsearch\_sync\client\_base.py", line 391, in perform_request
    method, path, params=params, headers=headers, body=body
  File "C:\Users\EDY\miniconda3\lib\site-packages\elasticsearch\_sync\client\_base.py", line 338, in perform_request
    body=resp_body,
elasticsearch.UnsupportedProductError: The client noticed that the server is not Elasticsearch and we do not support this unknown product

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

代码

from elasticsearch import Elasticsearch
es = Elasticsearch('http://101.43.x.x:9200')

# ignore 400 cause by IndexAlreadyExistsException when creating an index
es.indices.create(index='test-index', ignore=400)

# ignore 404 and 400
es.indices.delete(index='test-index', ignore=[400, 404])

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

解决

elasticsearch需要小于7.14.0的版本才可以

pip uninstall elasticsearch

//豆瓣镜像下载

pip install  elasticsearch==7.13.0   -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com
Looking in indexes: http://pypi.doubanio.com/simple/
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/367816
推荐阅读
相关标签
  

闽ICP备14008679号