搜索中的 Elasticsearch-py 无法识别 'analyzer' 参数()
Elasticsearch-py unrecognized 'analyzer' parameter in search()
API 文档说 search(*args, **kwargs)
有一个名为 analyzer
的参数。但以下代码引发异常:
RequestError:TransportError(400, 'illegal_argument_exception', 'request [/test-index/content-field/_search] contains unrecognized parameter: [analyzer]')
from elasticsearch import Elasticsearch
from elasticsearch.client import IndicesClient
es = Elasticsearch()
res = es.search(index="test-index", doc_type='content-field',
body={"query": {"match": {"text": "微观文明"}}},
analyzer="ik_smart", size=3)
不过下面的代码,returns答对了。
i=IndicesClient(es)
res=i.analyze(index="test-index",body="我你大家",analyzer="ik_smart")
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[.]
在这个 github 问题中找到了答案:https://github.com/elastic/elasticsearch-py/issues/495
API 文档说 search(*args, **kwargs)
有一个名为 analyzer
的参数。但以下代码引发异常:
RequestError:TransportError(400, 'illegal_argument_exception', 'request [/test-index/content-field/_search] contains unrecognized parameter: [analyzer]')
from elasticsearch import Elasticsearch
from elasticsearch.client import IndicesClient
es = Elasticsearch()
res = es.search(index="test-index", doc_type='content-field',
body={"query": {"match": {"text": "微观文明"}}},
analyzer="ik_smart", size=3)
不过下面的代码,returns答对了。
i=IndicesClient(es)
res=i.analyze(index="test-index",body="我你大家",analyzer="ik_smart")
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[.]
在这个 github 问题中找到了答案:https://github.com/elastic/elasticsearch-py/issues/495