API 文档说search(*args, **kwargs)
有一个名为analyzer
. 但是下面的代码引发了一个异常:
RequestError:TransportError(400, 'illegal_argument_exception', 'request [/test-index/content-field/_search] 包含无法识别的参数: [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)
但是,以下代码返回正确答案。
i=IndicesClient(es)
res=i.analyze(index="test-index",body="我你大家",analyzer="ik_smart")