asynces

Asyncio driver for Elasticsearch

APACHE-2.0 License

Downloads
119
Stars
3
Committers
2

asynces

Asyncio driver for Elasticsearch and Python 3.5+

Its goal is to create an asyncio transport for the official elasticsearch python driver.

The asynces package provides the AsyncElasticsearch class inherited from the Elasticsearch class (see elasticsearch).

All methods from the Elasticsearch class instance (see API doc) are available in the AsyncElasticsearch class instance.

Each API method returns coroutine that must be awaited.

Example of asynces usage:

import asyncio
from asynces import AsyncElasticsearch

async def test(loop):
    es = AsyncElasticsearch('http://127.0.0.1:9200/', loop=loop)
    doc = {'hello': 'world'}
    await es.index(index='my-index', doc_type='test', body=doc, refresh=False)
    await es.indices.refresh(index="my-index")
    ret = await es.search(index='my-index')
    print(ret)
    es.close()

loop = asyncio.get_event_loop()
loop.run_until_complete(test(loop))
loop.close()

Installation

First, you should install the latest version of elasticsearch compatible with your elasticsearch server version.

After that you should install asynces package:

pip install asynces