# Python API reindex issues

**URL:** <https://discuss.elastic.co/t/python-api-reindex-issues/196357>\
**Category:** Elasticsearch\
**Created:** [August 22, 2019, 3:05pm UTC](https://discuss.elastic.co/t/python-api-reindex-issues/196357 "2019-08-22T15:05:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![smhall316](https://avatars.discourse-cdn.com/v4/letter/s/e56c9b/32.png) [@smhall316](https://discuss.elastic.co/u/smhall316)\
**Post date:** [August 22, 2019, 3:05pm UTC](https://discuss.elastic.co/t/python-api-reindex-issues/196357/1 "2019-08-22T15:05:01Z")

</div>

I am relatively new to Elasticsearch so I have been playing with a bit using the Python API. I am using Elasticsearch service through AWS so I have been following its suggestions for restoring snapshots.

Since AWS does not allow me to close indices I create a temporary index and then use reindex to copy the documents from the temporary index to the default index. Both indices (the default and temp) have different number of documents. I expected that after calling reindex that the temp and default would have the same number of documents but it doesn't happen.

So for example I have two indices

- temp\_index with 1000 documents
- index with 900 documents

I expected after I reindexed temp\_index to index that index would now have 1000 documents but it still shows 900. Is there something I am missing with how reindex works?

---

<div class="post-metadata">

**Author:** ![HenningAndersen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/henningandersen/32/48188_2.png) [@HenningAndersen](https://discuss.elastic.co/u/HenningAndersen)\
**Post date:** [August 22, 2019, 6:39pm UTC](https://discuss.elastic.co/t/python-api-reindex-issues/196357/2 "2019-08-22T18:39:15Z")

</div>

Hi @smhall316,

I wonder if you can supply information on the reindex request and response? Also, the version of Elasticsearch is always good information.

Are the numbers given the real numbers for doc counts in the two indexes or are they example numbers?

---

<div class="post-metadata">

**Author:** ![smhall316](https://avatars.discourse-cdn.com/v4/letter/s/e56c9b/32.png) [@smhall316](https://discuss.elastic.co/u/smhall316)\
**Post date:** [August 23, 2019, 1:31pm UTC](https://discuss.elastic.co/t/python-api-reindex-issues/196357/3 "2019-08-23T13:31:07Z")

</div>

Hi @HenningAndersen,

Thanks for the quick reply. I think I figured out what was happening or at least what I think is happening.

I was calling restore and reindex within the same function and I was getting some HTTP 503 errors. Sometimes there were some partial reindexing of the index and other times there was none. The python API seems to have a predetermined number of retries when the service is not available.

I found that if I wait a few seconds between restore and reindex everything works. So I am guessing that my Elasticsearch instance wasn't fully done with the restore when I called the reindex. Does this make sense, is my understanding correct?

BTW, I am using Elasticsearch 5.5

---

<div class="post-metadata">

**Author:** ![HenningAndersen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/henningandersen/32/48188_2.png) [@HenningAndersen](https://discuss.elastic.co/u/HenningAndersen)\
**Post date:** [August 23, 2019, 5:17pm UTC](https://discuss.elastic.co/t/python-api-reindex-issues/196357/4 "2019-08-23T17:17:18Z")

</div>

Hi @smhall316,

yes, that sounds like a plausible explanation. Restore by default runs async. You can use `wait_for_completion=true` to make the request wait until the restore operation has completed.

---

<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:** [September 20, 2019, 5:17pm UTC](https://discuss.elastic.co/t/python-api-reindex-issues/196357/5 "2019-09-20T17:17:27Z")

</div>

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