Commit 2eae195b authored by Decoupes Remy's avatar Decoupes Remy
Browse files

elastic scrolling: fix a bug: we didn't take into account the first page

parent 54665db9
......@@ -22,10 +22,13 @@ def elastic_pagination_scrolling(result, headers):
:param result: a result of a ElasticSearcg query
:return:
"""
scroll_size = result['hits']['total']["value"]
results = []
scroll_size_total = result['hits']['total']["value"]
# Progress bar
pbar = tqdm(total=scroll_size)
pbar = tqdm(total=scroll_size_total)
results = []
results += result['hits']['hits'] # we add the first pages of results before scrolling
scroll_size = len(results)
pbar.update(scroll_size)
while (scroll_size > 0):
try:
scroll_id = result['_scroll_id']
......@@ -42,7 +45,6 @@ def elastic_pagination_scrolling(result, headers):
results += res['hits']['hits']
scroll_size = len(res['hits']['hits'])
pbar.update(scroll_size)
print(scroll_size)
except:
pbar.close()
break
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment