The Elasticsearch-py API Document says that search(args, *kwargs) function has a parameter called 'analyzer'.
But the following code raise a 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")
PS: I am using version 5.0.1 for Elasticsearch-py and version 5.0.0 for elasticsearch.
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"}}}})
Hope this helps
Thank you so much! It helps!But I have to say the API document is kind of misleading.I suggest you add some explanation there.It's easy for those people who are quite familiar with Elasticsearch to find the mistake but not for the new beginners.
Thanks again!
发自网易邮箱大师
On 11/28/2016 18:58, Honza Králnotifications@github.comwrote:
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"}}}})
Hope this helps
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
Most helpful comment
That parameter is only used (and accepted) when using the
qparameter to search via a query string. In your case you need to specify theanalyzerfor thematchquery in the body:Hope this helps