code: def scan(self, index, doc_type, query=None, scroll='5m', preserve_order=False, size=10, **kwargs):
          
          if not preserve_order:
              kwargs['search_type'] = 'scan'
          # initial search
          results = yield self.search(index=index,
                                      doc_type=doc_type,
                                      body=query,
                                      size=size,
                                      scroll=scroll,
                                      **kwargs)
  
          returnValue(Scroller(self, results, scroll, size))
docs: Simple abstraction on top of the
          :meth:`~elasticsearch.Elasticsearch.scroll` api - a simple iterator that
          yields all hits as returned by underlining scroll requests.
  
          By default scan does not return results in any pre-determined order. To
          have a standard order in the returned documents (either by score or
          explicit sort definition) when scrolling, use ``preserve_order=True``. This
          may be an expensive operation and will negate the performance benefits of
          using ``scan``.
          :param index: the index to query on
          :param doc_type: the doc_type to query on
          :param query: body for the :meth:`~elasticsearch.Elasticsearch.search` api
          :param scroll: Specify how long a consistent view of the index should be
              maintained for scrolled search
          :param preserve_order: don't set the ``search_type`` to ``scan`` - this will
              cause the scroll to paginate with preserving the order. Note that this
              can be an extremely expensive operation and can easily lead to
              unpredictable results, use with caution.
          :param size: the number of results to fetch in each scroll query
  
          Any additional keyword arguments will be passed to the initial
          :meth:`~elasticsearch.Elasticsearch.search` call::
  
              scan(index="coding_languages",
                  doc_type="languages_description",
                  query={"query": {"match": {"title": "python"}}},
                  index="orders-*",
                  doc_type="books"
              )