当前位置: 首页 > news >正文

Python查询ES错误ApiError(406, ‘Content-Type ...is not supported

现象

使用python查询es数据时出现下面错误

Traceback (most recent call last):File "getUsers.py", line 26, in <module>response = es.search(index="lizz_users", body=query)File "/usr/local/lib/python3.6/site-packages/elasticsearch/_sync/client/utils.py", line 402, in wrappedreturn api(*args, **kwargs)File "/usr/local/lib/python3.6/site-packages/elasticsearch/_sync/client/__init__.py", line 3734, in search"POST", __path, params=__query, headers=__headers, body=__bodyFile "/usr/local/lib/python3.6/site-packages/elasticsearch/_sync/client/_base.py", line 321, in perform_requestmessage=message, meta=meta, body=resp_body
elasticsearch.ApiError: ApiError(406, 'Content-Type header [application/vnd.elasticsearch+json; compatible-with=8] is not supported', 'Content-Type header [application/vnd.elasticsearch+json; compatible-with=8] is not supported')

原因

python安装的Elasticsearch版本与es服务的版本不一致

解决办法

查看es版本

curl  http://172.11.111.11:9200/{"name" : "bike-es-ssd-1","cluster_name" : "bike-user","cluster_uuid" : "9QixMq6dTpeDO-WEfnq_PA","version" : {"number" : "7.6.0","build_flavor" : "default","build_type" : "rpm","build_hash" : "7f634e9f44834fbc12724506cc1da681b0c3b1e3","build_date" : "2020-02-06T00:09:00.449973Z","build_snapshot" : false,"lucene_version" : "8.4.0","minimum_wire_compatibility_version" : "6.8.0","minimum_index_compatibility_version" : "6.0.0-beta1"},"tagline" : "You Know, for Search"
}
  • 可以看到es版本为7.6.0

重新安装python插件

pip3 install elasticsearch==7.6.0

搞定,执行,成功

http://www.dtcms.com/a/188238.html

相关文章:

  • 【传感器多模态融合与AI驱动】
  • Leetcode 3548. Equal Sum Grid Partition II
  • 常见网卡接口命名方式
  • OpenAI for Countries:全球AI基础设施的“技术基建革命”
  • 苍穹外卖--新增菜品
  • 新华三H3CNE网络工程师认证—路由参数与比较
  • Gartner《如何有效融合Data Fabric 与Data Mesh数据战略》学习心得
  • DeepBook 与 CEX 的不同
  • github 上的 CI/CD 的尝试
  • 【言语】刷题3
  • visual studio生成动态库DLL
  • 【MySQL】MySQL数据库结构与操作
  • QT 插槽实现
  • WebpackVite总结篇与进阶
  • Kotlin 中的 Unit 类型的作用以及 Java 中 Void 的区别
  • 2025深圳杯D题法医物证多人身份鉴定问题四万字思路
  • Rodrigues旋转公式-绕任意轴旋转
  • FPGA图像处理(六)------ 图像腐蚀and图像膨胀
  • 智能手表整机装配作业指导书(SOP)
  • 贪吃蛇游戏排行榜模块开发总结:从数据到视觉的实现
  • AI 编程新时代!字节 Seed-Coder 重磅登场
  • 在Babylon.js中实现完美截图的艺术:包含Canvas和HTML覆盖层
  • 在Flutter上如何实现按钮的拖拽效果
  • SQL 索引优化指南:原理、知识点与实践案例
  • cocos creator 3.8 下的 2D 改动
  • C++的历史与发展
  • 特征偏移、标签偏移、数量偏移、概念漂移分别是什么?
  • 共享代理IP带宽受限影响大吗
  • 【经验总结】【乘法替换方法】
  • 无线定位之四 SX1302 网关源码 thread_jit 线程详解