Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clearing Scroll while deleting elements from Elastic search

Should we clear scrolls everytime whenever we are deleting some items from the elastic search cluster? What impact will it have if we don't do that?

I saw in some example code, that for deletion, before deleting the items, it first searches the elements and then clear scrolls for that.

like image 867
hatellla Avatar asked Feb 03 '26 09:02

hatellla


1 Answers

From the Elasticsearch documentation:

The results that are returned from a scroll request reflect the state of the index at the time that the initial search request was made, like a snapshot in time. Subsequent changes to documents (index, update or delete) will only affect later search requests.

Therefore, you don't need to delete the scroll context. In fact, you never need to delete the context as it will eventually delete itself. However, it is best practice to delete the scroll context when you are finished to free up resources.

One use-case for the situation you described would be to see if the program is still using the outdated documents. Depending on the code, you may not want it to be using deleted documents and instead want to retrieve a fresh scroll context.

like image 73
Dennis Avatar answered Feb 05 '26 00:02

Dennis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!