How to fix error ElasticHttpError: (406, u'Content-Type header [] is not supported')
I encountered following error while running the search command on ElasticSearch
es.search(query,index='index1')
ElasticHttpError: (406, u'Content-Type header [] is not supported')
This occurs because of mismatch between ElasticSearch and Python Package ElasticSearch. Upgrade the ElasticSearch
pip install -U elasticsearch
This should resolve the error.
However there is work around too, just run the curl command directly. I use the package "sh" to do that...
import sh
sh.curl('-XGET', 'http://localhost:9200/_search?pretty=true', '-H', 'Content-Type: application/json', '-d', '{"query": {"match": {"package": "package1"}}}')