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:
parent
d794a52ff8
commit
dea74450ca
@ -468,7 +468,7 @@ class ElasticsearchSearchResults(BaseSearchResults):
|
|||||||
|
|
||||||
while True:
|
while True:
|
||||||
if len(page['hits']['hits']) == 0:
|
if len(page['hits']['hits']) == 0:
|
||||||
return
|
break
|
||||||
|
|
||||||
# Get pks from results
|
# Get pks from results
|
||||||
pks = [hit['fields']['pk'][0] for hit in page['hits']['hits']]
|
pks = [hit['fields']['pk'][0] for hit in page['hits']['hits']]
|
||||||
@ -494,13 +494,20 @@ class ElasticsearchSearchResults(BaseSearchResults):
|
|||||||
limit -= 1
|
limit -= 1
|
||||||
|
|
||||||
if limit == 0:
|
if limit == 0:
|
||||||
return
|
break
|
||||||
|
|
||||||
|
if limit is not None and limit == 0:
|
||||||
|
break
|
||||||
|
|
||||||
# Fetch next page of results
|
# Fetch next page of results
|
||||||
if '_scroll_id' not in page:
|
if '_scroll_id' not in page:
|
||||||
return
|
break
|
||||||
|
|
||||||
page = self.backend.es.scroll(scroll_id=page['_scroll_id'], scroll='2m')
|
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:
|
else:
|
||||||
params.update({
|
params.update({
|
||||||
'size': limit or PAGE_SIZE,
|
'size': limit or PAGE_SIZE,
|
||||||
|
Loading…
Reference in New Issue
Block a user