Search code examples
pythonelasticsearchcontent-type

How to change the Content-Type in *aioes*


I'm using the library aioes and when I try to execute this script:

from aioes import Elasticsearch

import asyncio


@asyncio.coroutine
def check():
    host = 'localhost'
    port = 1234

    es = Elasticsearch(['{host}:{port}'.format(host=host, port=port)])

    answer = yield from es.search(index="test-index", body={})
    print(answer)


loop = asyncio.get_event_loop()
loop.run_until_complete(check())

I get this error: aioes.exception.TransportError: TransportError(406, '{"error":"Content-Type header [application/octet-stream] is not supported","status":406}')

I've tried to go through the Internet, but I haven't found any solution. Where am I wrong?


Solution

  • aioes has been abandoned and I don't think it supports ES6.0 and above, which require the content header to be specified. If you check out the aioes github they recommend the 'official' ES python client now.

    https://github.com/aio-libs-abandoned/aioes