python执行elasticsearch异常【已解决】

简介: 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可以用于搜索各种文档。它提供可扩展的搜索,具有接近实时的搜索,并支持多租户。
目录
相关文章
|
20天前
|
人工智能 Shell 开发工具
[oeasy]python065python报错怎么办_try_试着来_except_发现异常
本文介绍了Python中处理异常的基本方法,重点讲解了`try`和`except`的用法。通过一个计算苹果重量的小程序示例,展示了如何捕获用户输入错误并进行处理。主要内容包括: 1. **回顾上次内容**:简要回顾了Shell环境、Python3游乐场和Vim编辑器的使用。 2. **编写程序**:编写了一个简单的程序来计算苹果的总重量,但发现由于输入类型问题导致结果错误。 3. **调试与修正**:通过调试发现输入函数返回的是字符串类型,需要将其转换为整数类型才能正确计算。
51 32
|
17天前
|
数据库 Python
[oeasy]python066_如何捕获多个异常_try_否则_else_exception
本文介绍了Python中`try...except...else`结构的使用方法。主要内容包括: 1. **回顾上次内容**:简要复习了`try`和`except`的基本用法,强调了异常处理的重要性。 2. **详细解释**: - `try`块用于尝试执行代码,一旦发现错误会立即终止并跳转到`except`块。 - `except`块用于捕获特定类型的异常,并进行相应的处理。 - `else`块在没有异常时执行,是可选的。 3. **示例代码**:通过具体例子展示了如何捕获不同类型的异常(如`ValueError`和`ZeroDivisionError`),并解释了异常处理
43 24
|
4月前
|
测试技术 开发者 Python
对于Python中的异常要如何处理,raise关键字你真的了解吗?一篇文章带你从头了解
`raise`关键字在Python中用于显式引发异常,允许开发者在检测到错误条件时中断程序流程,并通过异常处理机制(如try-except块)接管控制。`raise`后可跟异常类型、异常对象及错误信息,适用于验证输入、处理错误、自定义异常、重新引发异常及测试等场景。例如,`raise ValueError(&quot;Invalid input&quot;)`用于验证输入数据,若不符合预期则引发异常,确保数据准确并提供清晰错误信息。此外,通过自定义异常类,可以针对特定错误情况提供更具体的信息,增强代码的健壮性和可维护性。
|
4月前
|
Python
在Python中,`try...except`语句用于捕获和处理程序运行时的异常
在Python中,`try...except`语句用于捕获和处理程序运行时的异常
98 5
|
4月前
|
Python
在Python中,自定义函数可以抛出自定义异常
在Python中,自定义函数可以抛出自定义异常
86 5
|
4月前
|
存储 开发者 Python
自定义Python的异常
自定义Python的异常
41 5
|
5月前
|
存储 索引 Python
Python生成器、装饰器、异常(2)
【10月更文挑战第16天】
69 1
Python生成器、装饰器、异常(2)
|
8月前
|
索引 Python
【Python】已解决:elasticsearch.exceptions.RequestError: TransportError(400, ‘search_phase_execution_exc
【Python】已解决:elasticsearch.exceptions.RequestError: TransportError(400, ‘search_phase_execution_exc
451 0
|
5月前
|
Python
Python生成器、装饰器、异常
【10月更文挑战第15天】
39 2
|
5月前
|
设计模式 安全 JavaScript
Python学习八:面向对象编程(下):异常、私有等
这篇文章详细介绍了Python面向对象编程中的私有属性、私有方法、异常处理及动态添加属性和方法等关键概念。
48 1

热门文章

最新文章