When using ElasticSearch scroll api, can I skip to page n?
<p>I'm using the elasticsearch scroll api. In some cases I'd like to return the hits on page n without returning the previous pages' hits. I believe this should be like an iterator. So I'd like to just pass the iterator through the first few pages, but then actually return the hits of the n-th page. </p>

<p>My current code is </p>

<pre><code>initial_request = client.search(index = index, doc_type = doc_type, body = q, scroll = str(wait_time) + 'm', search_type = 'scan', size = size) 

sid = initial_request['_scroll_id'] ## scroll id
total_hits = initial_request['hits']['total'] ## how many results there are. 
scroll_size = total_hits ## set this to a positive value initially

while scroll_size &gt; 0:

    p += 1
    print "\t\t Scrolling to page %s ..." %p

    page = client.scroll(scroll_id = sid, scroll = str(wait_time) + 'm')

    sid = page['_scroll_id'] # Update the scroll ID
    scroll_size = len(page["hits"]["hits"]) ## no. of hits returned on this page
    ## then code to do stuff w/ that page's hits. 
</code></pre>

<p>but the <code>page = client.scroll(...)</code> actually sends the hits for that page back to my local machine. I'd like to just <code>pass</code> on the first n pages, then start sending the pages' hits after that. </p>

<p>Any ideas? </p>

<p>Elasticsearch python client <code>search</code> method allows you to specify the <code>size</code> and <code>from_</code> argument to start searching for elements for a <code>query</code> skipping a few records.</p>

<pre><code>client.search(index=ES_INDEX, body=QUERY, doc_type=ES_TYPE, size=SIZE,from_=FROM)
</code></pre>

python elasticsearch pagination iterator