I am using elasticsearch api scrollbar. In some cases, I would like to return hits on page n without returning hits from previous pages. I believe it should be like an iterator. So I would just like to pass the iterator through the first few pages, but then actually return the hits of the nth page.
My current 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']
total_hits = initial_request['hits']['total']
scroll_size = total_hits
while scroll_size > 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']
scroll_size = len(page["hits"]["hits"])
but page = client.scroll(...)sends hits of this page back to my local machine. I would just like passon the first n pages, and then start sending page images after that.
Any ideas?
source
share