Scroll search should clear the scroll at the end (#1331)

This commit is contained in:
Tomas Della Vedova
2020-10-12 10:46:51 +02:00
committed by GitHub
parent 5682e680d1
commit ea009da3b6
2 changed files with 65 additions and 46 deletions

View File

@ -104,13 +104,15 @@ class Helpers {
}
while (response.body.hits && response.body.hits.hits.length > 0) {
// scroll id is always present in the response, but it might
// change over time based on the number of shards
scroll_id = response.body._scroll_id
response.clear = clear
addDocumentsGetter(response)
yield response
if (!scroll_id || stop === true) {
if (stop === true) {
break
}
@ -127,6 +129,10 @@ class Helpers {
throw new ResponseError(response)
}
}
if (stop === false) {
await clear()
}
}
/**