

def scan(client, query=None, scroll='5m', preserve_order=False, **kwargs):
    '\n    Simple abstraction on top of the\n    :meth:`~elasticsearch.Elasticsearch.scroll` api - a simple iterator that\n    yields all hits as returned by underlining scroll requests.\n\n    :arg client: instance of :class:`~elasticsearch.Elasticsearch` to use\n    :arg query: body for the :meth:`~elasticsearch.Elasticsearch.search` api\n    :arg scroll: Specify how long a consistent view of the index should be\n        maintained for scrolled search\n    :arg preserve_order: don\'t set the ``search_type`` to ``scan`` - this will\n        cause the scroll to paginate with preserving the order. Note that this\n        can be an extremely expensive operation and can easily lead to\n        unpredictable results, use with caution.\n\n    Any additional keyword arguments will be passed to the initial\n    :meth:`~elasticsearch.Elasticsearch.search` call::\n\n        scan(es,\n            query={"match": {"title": "python"}},\n            index="orders-*",\n            doc_type="books"\n        )\n\n    '
    if (not preserve_order):
        kwargs['search_type'] = 'scan'
    resp = client.search(body=query, scroll=scroll, **kwargs)
    scroll_id = hit.get('_scroll_id')
    if (scroll_id is None):
        return
    first_run = True
    while True:
        if (preserve_order and first_run):
            first_run = False
        else:
            resp = client.scroll(scroll_id, scroll=scroll)
        if (not resp['hits']['hits']):
            break
        for hit in resp['hits']['hits']:
            (yield hit)
        scroll_id = resp.get('_scroll_id')
        if (scroll_id is None):
            break

dataset/ETHPy150Open hvandenb/splunk-elasticsearch/search-elasticsearch/bin/elasticsearch/helpers/__init__.py scan/VarMisuse@63/435 `resp`->`hit`