API文檔說search(*args, **kwargs)
有一個名爲analyzer
的參數。但是,下面的代碼會引發異常:Elasticsearch-py在搜索中無法識別'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)
下面的代碼,然而,返回一個正確的答案。
i=IndicesClient(es)
res=i.analyze(index="test-index",body="我你大家",analyzer="ik_smart")