Reputation: 18525
How to perform the calling of
POST my_index/_analyze
{
"analyzer": "german_analyzer",
"text": "kann"
}
in python elastic search 6.x api?
I tried
def get_es():
# Variables for Elasticsearch host+port
es_host = 'localhost'
es_port = 9200
from elasticsearch import Elasticsearch
es = Elasticsearch([{'host': es_host, 'port': es_port}])
return es
if __name__ == '__main__':
es = get_es()
body={
"analyzer": "german_analyzer",
"text": "kann"
}
result = es.search(index="faq-kbaid-de-index", body=body,
size=1)
i=1
it gives exception
elasticsearch.exceptions.RequestError: RequestError(400, 'parsing_exception', 'Unknown key for a VALUE_STRING in [analyzer].')
Upvotes: 4
Views: 932
Reputation: 753
es.search()
calles _search
. You can call _analyze
via elasticsearch.client.IndicesClient. Replace the .search
line with
result = es.indices.analyze(index="faq-kbaid-de-index", body=body,
size=1)
Upvotes: 3