python执行elasticsearch异常【已解决】

python执行elasticsearch异常【已解决】,第1张

网站已上线 ,不妨来看看留个言 : 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

代码
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])

解决

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/

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/734469.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-27
下一篇 2022-04-27

发表评论

登录后才能评论

评论列表(0条)

保存