

def bulk(client, actions, stats_only=False, **kwargs):
    '\n    Helper for the :meth:`~elasticsearch.Elasticsearch.bulk` api that provides\n    a more human friendly interface - it consumes an iterator of actions and\n    sends them to elasticsearch in chunks. It returns a tuple with summary\n    information - number of successfully executed actions and either list of\n    errors or number of errors if `stats_only` is set to `True`.\n\n    See :func:`~elasticsearch.helpers.streaming_bulk` for more information\n    and accepted formats.\n\n    :arg client: instance of :class:`~elasticsearch.Elasticsearch` to use\n    :arg actions: iterator containing the actions\n    :arg stats_only: if `True` only report number of successful/failed\n        operations instead of just number of successful and a list of error responses\n\n    Any additional keyword arguments will be passed to\n    :func:`~elasticsearch.helpers.streaming_bulk` which is used to execute\n    the operation.\n    '
    (success, failed) = (0, 0)
    errors = []
    for (ok, item) in streaming_bulk(client, actions, **kwargs):
        if (not ok):
            if (not stats_only):
                errors.append(item)
            failed += 1
        else:
            success += 1
    return (success, (stats_only if stats_only else errors))

dataset/ETHPy150Open hvandenb/splunk-elasticsearch/search-elasticsearch/bin/elasticsearch/helpers/__init__.py bulk/VarMisuse@101/431 `failed`->`stats_only`