

def reindex(client, source_index, target_index, query=None, target_client=None, chunk_size=500, scroll='5m', scan_kwargs={
    
}, bulk_kwargs={
    
}):
    "\n    Reindex all documents from one index that satisfy a given query\n    to another, potentially (if `target_client` is specified) on a different cluster.\n    If you don't specify the query you will reindex all the documents.\n\n    .. note::\n\n        This helper doesn't transfer mappings, just the data.\n\n    :arg client: instance of :class:`~elasticsearch.Elasticsearch` to use (for\n        read if `target_client` is specified as well)\n    :arg source_index: index (or list of indices) to read documents from\n    :arg target_index: name of the index in the target cluster to populate\n    :arg query: body for the :meth:`~elasticsearch.Elasticsearch.search` api\n    :arg target_client: optional, is specified will be used for writing (thus\n        enabling reindex between clusters)\n    :arg chunk_size: number of docs in one chunk sent to es (default: 500)\n    :arg scroll: Specify how long a consistent view of the index should be\n        maintained for scrolled search\n    :arg scan_kwargs: additional kwargs to be passed to\n        :func:`~elasticsearch.helpers.scan`\n    :arg bulk_kwargs: additional kwargs to be passed to\n        :func:`~elasticsearch.helpers.bulk`\n    "
    target_client = (client if (target_client is None) else target_client)
    docs = scan(client, query=query, index=source_index, scroll=scroll, **scan_kwargs)

    def _change_doc_index(hits, index):
        for h in hits:
            h['_index'] = index
            (yield h)
    return bulk(target_client, _change_doc_index(docs, target_index), chunk_size=chunk_size, stats_only=True, **bulk_kwargs)

dataset/ETHPy150Open hvandenb/splunk-elasticsearch/search-elasticsearch/bin/elasticsearch/helpers/__init__.py reindex/original