# How do I get to know that reindexing has been completed in Elasticsearch python client?

**URL:** https://discuss.elastic.co/t/how-do-i-get-to-know-that-reindexing-has-been-completed-in-elasticsearch-python-client/349670
**Category:** Elasticsearch
**Tags:** reindex
**Created:** [December 19, 2023, 5:22pm UTC](https://discuss.elastic.co/t/how-do-i-get-to-know-that-reindexing-has-been-completed-in-elasticsearch-python-client/349670 "2023-12-19T17:22:12Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Aditya\_Dubey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aditya_dubey/32/130162_2.png) [@Aditya\_Dubey](https://discuss.elastic.co/u/Aditya_Dubey)
#### Post date: [December 19, 2023, 5:22pm UTC](https://discuss.elastic.co/t/how-do-i-get-to-know-that-reindexing-has-been-completed-in-elasticsearch-python-client/349670/1 "2023-12-19T17:22:12Z")

</div>

Basically, I'm running a reindexing function, and immediately after that, I'm running a function to delete the source index. Python runs all lines of code for the first function and moves to the next function (delete index).

Sometimes the reindexing isn't performed and the source index gets deleted, causing data loss.

I want to add either a Boolean field or any sort of flag that indicates that reindexing has been completed so that I can move on with the delete function.

---

<div class="post-metadata">

### Author: ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)
#### Post date: [December 19, 2023, 7:22pm UTC](https://discuss.elastic.co/t/how-do-i-get-to-know-that-reindexing-has-been-completed-in-elasticsearch-python-client/349670/2 "2023-12-19T19:22:18Z")

</div>

Hi @Aditya_Dubey

If you are using the [Reindex API](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html#docs-reindex) you can use the parameter [wait\_for\_completion](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html#docs-reindex-task-api) = false to run async and receive a taks id.

With this task id you can check whether the reindexing has finished and thus perform the operation to remove the index.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [January 16, 2024, 7:23pm UTC](https://discuss.elastic.co/t/how-do-i-get-to-know-that-reindexing-has-been-completed-in-elasticsearch-python-client/349670/3 "2024-01-16T19:23:17Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
