title: Elasticsearch get search results in batches?
body: <p>When I am querying Elasticsearch with the Python Elasticsearch API, I get around 5000 results. Setting the "size" parameter in the search query to a larger number than the number of results leads to the following Java OOM error:</p>
  
  <pre><code>File "MGDFinder.py", line 114, in &lt;module&gt;
    res = es.search(index="_all", body=queryMaker(state))
  File "/usr/local/lib/python2.7/dist-packages/elasticsearch/client/utils.py", line 68, in _wrapped
    return func(*args, params=params, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/elasticsearch/client/__init__.py", line 440, in search
    params=params, body=body)
  File "/usr/local/lib/python2.7/dist-packages/elasticsearch/transport.py", line 276, in perform_request
    status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
  File "/usr/local/lib/python2.7/dist-packages/elasticsearch/connection/http_urllib3.py", line 55, in perform_request
    self._raise_error(response.status, raw_data)
  File "/usr/local/lib/python2.7/dist-packages/elasticsearch/connection/base.py", line 97, in _raise_error
    raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
  elasticsearch.exceptions.TransportError: TransportError(500, u'OutOfMemoryError[Java heap space]')
  </code></pre>
  
  <p>I notice that this happens when the size is set to even just 700. I don't want to increase my Java heap size. Is there a way I can perform my search in batches of 500?</p>