python执行elasticsearch异常【已解决】

本文涉及的产品
检索分析服务 Elasticsearch 版,2核4GB开发者规格 1个月
简介: python执行elasticsearch异常【已解决】

异常

异常信息

$ 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/
相关实践学习
使用阿里云Elasticsearch体验信息检索加速
通过创建登录阿里云Elasticsearch集群,使用DataWorks将MySQL数据同步至Elasticsearch,体验多条件检索效果,简单展示数据同步和信息检索加速的过程和操作。
ElasticSearch 入门精讲
ElasticSearch是一个开源的、基于Lucene的、分布式、高扩展、高实时的搜索与数据分析引擎。根据DB-Engines的排名显示,Elasticsearch是最受欢迎的企业搜索引擎,其次是Apache Solr(也是基于Lucene)。 ElasticSearch的实现原理主要分为以下几个步骤: 用户将数据提交到Elastic Search 数据库中 通过分词控制器去将对应的语句分词,将其权重和分词结果一并存入数据 当用户搜索数据时候,再根据权重将结果排名、打分 将返回结果呈现给用户 Elasticsearch可以用于搜索各种文档。它提供可扩展的搜索,具有接近实时的搜索,并支持多租户。
目录
相关文章
|
2月前
|
索引 Python
【Python】已解决:elasticsearch.exceptions.RequestError: TransportError(400, ‘search_phase_execution_exc
【Python】已解决:elasticsearch.exceptions.RequestError: TransportError(400, ‘search_phase_execution_exc
118 0
|
2月前
|
Unix API Python
【Python】已完美解决:(Python3.8异常)AttributeError: module ‘time‘ has no attribute ‘clock‘
【Python】已完美解决:(Python3.8异常)AttributeError: module ‘time‘ has no attribute ‘clock‘
61 0
|
2月前
|
数据采集 存储 Java
如何让Python爬虫在遇到异常时继续运行
构建健壮Python爬虫涉及异常处理、代理IP和多线程。通过try/except捕获异常,保证程序在遇到问题时能继续运行。使用代理IP(如亿牛云)防止被目标网站封锁,多线程提升抓取效率。示例代码展示了如何配置代理,设置User-Agent,以及使用SQLite存储数据。通过`fetch_url`函数和`ThreadPoolExecutor`实现抓取与重试机制。
如何让Python爬虫在遇到异常时继续运行
|
1月前
|
API C++ Python
【Azure 应用服务】Python fastapi Function在Azure中遇见AttributeError异常(AttributeError: 'AsgiMiddleware' object has no attribute 'handle_async')
【Azure 应用服务】Python fastapi Function在Azure中遇见AttributeError异常(AttributeError: 'AsgiMiddleware' object has no attribute 'handle_async')
|
2月前
|
机器学习/深度学习 运维 监控
使用Python实现深度学习模型:智能安防监控与异常检测
【7月更文挑战第26天】 使用Python实现深度学习模型:智能安防监控与异常检测
51 6
|
1月前
|
存储 Python
Python 中的用户定义异常
【8月更文挑战第23天】
21 0
|
1月前
|
前端开发 JavaScript Java
Python错误、异常和模块
本文详细介绍了Python编程中的错误和异常处理以及模块的使用方法。语法错误如遗漏引号会导致`SyntaxError`,而运行时错误如除以零则会产生`ZeroDivisionError`等异常。文章通过实例展示了如何使用`try...except`结构来捕获并处理异常,确保程序的健壮性。此外,还介绍了如何自定义异常以及主动抛出异常的方法。在模块方面,文章解释了如何创建和导入模块以重用代码,并展示了不同导入方式的特点,包括导入单个函数、全部内容等。最后提到了Python标准库的使用和查询模块内容的方法。
|
1月前
|
运维 安全 网络协议
运维.索引引擎ElasticSearch.记录一个小异常:received plaintext http traffic on an https channel
运维.索引引擎ElasticSearch.记录一个小异常:received plaintext http traffic on an https channel
134 0
|
2月前
|
机器学习/深度学习 数据采集 算法
Python实现Prophet时间序列数据建模与异常值检测(Prophet算法)项目实战
Python实现Prophet时间序列数据建模与异常值检测(Prophet算法)项目实战
172 2