elasticsearch-py icon indicating copy to clipboard operation
elasticsearch-py copied to clipboard

Make failing document available when using the bulk helper

Open bralbral opened this issue 3 years ago • 1 comments

According to documentation :

import asyncio
from elasticsearch import AsyncElasticsearch
from elasticsearch.helpers import async_bulk

es = AsyncElasticsearch()

async def gendata():
    mywords = ['foo', 'bar', 'baz']
    for word in mywords:
        yield {
            "_index": "mywords",
            "word": word,
        }

async def main():
    async for ok, result in async_streaming_bulk(es, gendata()):
        action, result = result.popitem()
        if not ok:
            print("failed to %s document %s" % ())

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

but neither actions nor result contains information about the original event.

How can i get error events?

bralbral avatar Feb 06 '22 10:02 bralbral

Currently there's no way to get this information from the returned error, this would be good to have though. I'm going to convert this into a feature suggestion issue.

sethmlarson avatar Feb 17 '22 20:02 sethmlarson