已解决elasticsearch.exceptions.RequestError: TransportError(400, ‘search_phase_execution_exception’, ‘[
Posted 无 羡ღ
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了已解决elasticsearch.exceptions.RequestError: TransportError(400, ‘search_phase_execution_exception’, ‘[相关的知识,希望对你有一定的参考价值。
已解决(python操作elasticsearch模块查询失败)elasticsearch.exceptions.RequestError: TransportError(400, ‘search_phase_execution_exception’, ‘[terms] query does not support [ti]’)
文章目录
报错代码
粉丝群里面的一个小伙伴想用python操作elasticsearch 模块查询数据(当时他心里瞬间凉了一大截,跑来找我求助,然后顺利帮助他解决了,顺便记录一下希望可以帮助到更多遇到这个bug不会解决的小伙伴),报错代码如下::
from elasticsearch import Elasticsearch
es = Elasticsearch(["host": "服务器地址", "port": 端口号])
print(es.ping)
apids = '小鹏'
body = "_source":
"include": ["ap"],
"query":
"bool": "must": [
"terms": "ti": apids
],
, "size": 10000
data = es.search(index='库名',doc_type='表名',body=body,size=10)
print(data)
报错信息如下:
elasticsearch.exceptions.RequestError: TransportError(400, ‘search_phase_execution_exception’, ‘[terms] query does not support [ti]’)
报错翻译
报错信息翻译:
弹性搜索.例外.请求错误:错误(400, ‘搜索阶段执行异常’, ‘[terms] 查询不支持 [ti]’)
报错原因
报错原因:elasticsearch语句查询传参类型错误,小伙伴按下面的语法传参即可!!!
解决方法
正确的参数不是传递字符串,而是传递列表(列表内填写字符串):
apids = ['小鹏']
再次运行就成功了:
帮忙解决
本文已收录于:《告别Bug》专栏
本专栏用于记录学习和工作中遇到的各种疑难Bug问题,以及粉丝群里小伙伴提出的各种问题,文章形式:报错代码 + 报错翻译 + 报错原因 + 解决方法,包括程序安装、运行程序过程中等等问题,订阅专栏+关注博主后如遇到其他问题可私聊帮忙解决!!!
以上是关于已解决elasticsearch.exceptions.RequestError: TransportError(400, ‘search_phase_execution_exception’, ‘[的主要内容,如果未能解决你的问题,请参考以下文章