Elasticsearch-py无法识别的分析仪'搜索中的参数()

时间:2016-11-25 05:03:35

标签: python elasticsearch-plugin query-analyzer

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")

1 个答案:

答案 0 :(得分:0)

  

使用q参数通过查询字符串进行搜索时,仅使用(并接受)该参数。在您的情况下,您需要在正文[。]

中为匹配查询指定分析器

在这个github问题中找到答案:php.net indicates: