0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Clear the scroll when we are done with it

This commit is contained in:
Karl Hobley 2017-04-13 11:27:30 +01:00
parent d794a52ff8
commit dea74450ca

View File

@ -468,7 +468,7 @@ class ElasticsearchSearchResults(BaseSearchResults):
while True:
if len(page['hits']['hits']) == 0:
return
break
# Get pks from results
pks = [hit['fields']['pk'][0] for hit in page['hits']['hits']]
@ -494,13 +494,20 @@ class ElasticsearchSearchResults(BaseSearchResults):
limit -= 1
if limit == 0:
return
break
if limit is not None and limit == 0:
break
# Fetch next page of results
if '_scroll_id' not in page:
return
break
page = self.backend.es.scroll(scroll_id=page['_scroll_id'], scroll='2m')
# Clear the scroll
if '_scroll_id' in page:
self.backend.es.clear_scroll(scroll_id=page['_scroll_id'])
else:
params.update({
'size': limit or PAGE_SIZE,