elasticsearch-py unrecognized parameter [analyzer]

sinat_16723955 2016-11-26 12:47:59
代码如下:
from elasticsearch import Elasticsearch
es=Elasticsearch()
res=es.search(index="test-index",doc_type="content-field",body={"query":{"match":{"text":"微观文明"}}},analyzer="ik_smart")
程序运行报错:
Traceback (most recent call last):
File "E:/PycharmProjects/ElasticSearch/templates/search.py", line 11, in <module>
res = es.search(index="test-index", doc_type='content-field',body={"query": {"match": {"text": "微观文明"}}},analyzer="ik_smart")
File "E:\Python35\lib\site-packages\elasticsearch\client\utils.py", line 71, in _wrapped
return func(*args, params=params, **kwargs)
File "E:\Python35\lib\site-packages\elasticsearch\client\__init__.py", line 569, in search
doc_type, '_search'), params=params, body=body)
File "E:\Python35\lib\site-packages\elasticsearch\transport.py", line 327, in perform_request
status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
File "E:\Python35\lib\site-packages\elasticsearch\connection\http_urllib3.py", line 124, in perform_request
self._raise_error(response.status, raw_data)
File "E:\Python35\lib\site-packages\elasticsearch\connection\base.py", line 122, in _raise_error
raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.RequestError: TransportError(400, 'illegal_argument_exception', 'request [/test-index/content-field/_search] contains unrecognized parameters: [analyzer]')

我使用的elasticsearch版本是 elasticsearch5.0 https://github.com/medcl/elasticsearch-rtf
python版本是 python35

我已经在stackoverflow上提了问,挂了一晚上了,目前还没人回答。。。
http://stackoverflow.com/questions/40798042/elasticsearch-py-unrecognized-parameter-analyzer



...全文
815 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
sinat_16723955 2016-12-08
  • 打赏
  • 举报
回复
问题已经解决啦。 That parameter is only used (and accepted) when using the q parameter to search via a query string. In your case you need to specify the analyzer for the match query in the body: res= es.search(index="test-index", doc_type='content-field',body={"query": {"match": {"text": {"query": "微观文明", "analyzer": "ik_smart"}}}})

37,720

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧