aioes¶
aioes is a libarary for working with an ElasticSearch from asyncio framework.
Features¶
- Easy interface to ElasticSearch cluster.
- Modelled after elasticsearch-py. Not fully compatible due
yield from
nature of asyncio but looks very similar.
Basic Example¶
import asyncio
from aioes import Elasticsearch
@asyncio.coroutine
def go():
es = Elasticsearch(['localhost:9200'])
ret = yield from es.create(index="my-index",
doc_type="test-type",
id=42,
body={"str": "data",
"int": 1})
assert (ret == {'_id': '42',
'_index': 'my-index',
'_type': 'test-type',
'_version': 1,
'ok': True})
answer = yield from es.get(index="my-index",
doc_type="test-type",
id=42)
assert answer['_source'] == {'str': 'data', 'int': 1}
loop = asyncio.get_event_loop()
loop.run_until_complete(go())