# Index using Elasticsearch.py

**URL:** <https://discuss.elastic.co/t/index-using-elasticsearch-py/98174>\
**Category:** Elasticsearch\
**Created:** [August 24, 2017, 8:02am UTC](https://discuss.elastic.co/t/index-using-elasticsearch-py/98174 "2017-08-24T08:02:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jogoinar10](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jogoinar10/32/20068_2.png) [@jogoinar10](https://discuss.elastic.co/u/jogoinar10)\
**Post date:** [August 24, 2017, 8:02am UTC](https://discuss.elastic.co/t/index-using-elasticsearch-py/98174/1 "2017-08-24T08:02:06Z")

</div>

I want to reindex some data from other server to my new server. I want to use python script for this.  
I use the [elasticsearch.py](http://elasticsearch.py) plugin.

Does anyone here tried this?

I have a defficulty with regards to the body of the document.

```
index = es_dest.index(
 index = 'new_index',
 doc_type = log,
 id = 'asdadas',
 body = data_body
)

```

data\_body variable is the one that i got inside the `['hits']['hits']`

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [August 24, 2017, 11:17am UTC](https://discuss.elastic.co/t/index-using-elasticsearch-py/98174/2 "2017-08-24T11:17:43Z")

</div>

Hi @jogoinar10,

if your target cluster is on a somewhat recent version of Elasticsearch (5.0 or better), you can use [reindex-from-remote](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/docs-reindex.html#reindex-from-remote) without writing any code. Alternatively, there is the [Reindex helper](http://elasticsearch-py.readthedocs.io/en/master/helpers.html#reindex) in the Elasticsearch Python client which should greatly simplify your task.

Daniel

---

<div class="post-metadata">

**Author:** ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)\
**Post date:** [August 24, 2017, 1:44pm UTC](https://discuss.elastic.co/t/index-using-elasticsearch-py/98174/3 "2017-08-24T13:44:00Z")

</div>

You can also use [Elasticsearch Curator](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/reindex.html) for this, or its [Reindex API](http://curator.readthedocs.io/en/latest/actionclasses.html#reindex), which is Python.

---

<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 21, 2017, 1:44pm UTC](https://discuss.elastic.co/t/index-using-elasticsearch-py/98174/4 "2017-09-21T13:44:01Z")

</div>

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