# How to create auto generated ids while reindexing?

**URL:** <https://discuss.elastic.co/t/how-to-create-auto-generated-ids-while-reindexing/188782>\
**Category:** Elasticsearch\
**Created:** [July 3, 2019, 5:13pm UTC](https://discuss.elastic.co/t/how-to-create-auto-generated-ids-while-reindexing/188782 "2019-07-03T17:13:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![praveengadugin1](https://avatars.discourse-cdn.com/v4/letter/p/858c86/32.png) [@praveengadugin1](https://discuss.elastic.co/u/praveengadugin1)\
**Post date:** [July 3, 2019, 5:13pm UTC](https://discuss.elastic.co/t/how-to-create-auto-generated-ids-while-reindexing/188782/1 "2019-07-03T17:13:18Z")

</div>

On using reindex API for reindexing 5 TB of data, to make the process faster I would like to create auto generated ids for new index as mentioned here.How do we do it??

[https://www.elastic.co/guide/en/elasticsearch/reference/current/tune-for-indexing-speed.html#\_disable\_swapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/tune-for-indexing-speed.html#_disable_swapping)

---

<div class="post-metadata">

**Author:** ![gabriel\_tessier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_tessier/32/27911_2.png) [@gabriel\_tessier](https://discuss.elastic.co/u/gabriel_tessier)\
**Post date:** [July 4, 2019, 3:42am UTC](https://discuss.elastic.co/t/how-to-create-auto-generated-ids-while-reindexing/188782/2 "2019-07-04T03:42:27Z")

</div>

Hi @praveengadugin1 ,

As the name suggest auto-generated is automatic, so you just need to remove the id field that you have and reindex your data elastic will assign an auto-generated one in "\_id" field.

Check about ingest to remove the id field if you have one.

You can try:

```
POST my_index/_doc
{"foo": "bar"}

```

it will return:

```
{
  "_index" : "my_index",
  "_type" : "_doc",
  "_id" : "X80Qu2sBMcYBL_rB5lGJ",
  "_version" : 1,
  "result" : "created", 

```

the auto generated id is "X80Qu2sBMcYBL\_rB5lGJ"

Hope it help.

---

<div class="post-metadata">

**Author:** ![SudevPK](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@SudevPK](https://discuss.elastic.co/u/SudevPK)\
**Post date:** [July 4, 2019, 4:43am UTC](https://discuss.elastic.co/t/how-to-create-auto-generated-ids-while-reindexing/188782/3 "2019-07-04T04:43:03Z")

</div>

> [@How to change \_id as GUID during reindex](https://discuss.elastic.co/t/how-to-change-id-as-guid-during-reindex/182552):
>
> I have two different elastic search nodes.I need to reindex 10 indices from one node to 1 index in another node.But there is not unique id's in the 10 indices, so i need to generate \_id as GUID while reindexing

**I am linking my old post of same**  
Try

```
POST _reindex
{
  "source": {
    "index": ["twitter", "twitter2"]
  },
  "dest": {
    "index": "new_twitter"
  },
  "script": {
    "source": "ctx._id=null",
    "lang": "painless"
  }
}

```

---

<div class="post-metadata">

**Author:** ![gabriel\_tessier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_tessier/32/27911_2.png) [@gabriel\_tessier](https://discuss.elastic.co/u/gabriel_tessier)\
**Post date:** [July 4, 2019, 6:10am UTC](https://discuss.elastic.co/t/how-to-create-auto-generated-ids-while-reindexing/188782/4 "2019-07-04T06:10:43Z")

</div>

Hi,

With TB of data I guess that ingest may be faster than script but better to make your own bench and share it here it may be useful for other people.

About ingest you can use remove processor to remove the id field.  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/remove-processor.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/remove-processor.html)

---

<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:** [August 1, 2019, 6:10am UTC](https://discuss.elastic.co/t/how-to-create-auto-generated-ids-while-reindexing/188782/5 "2019-08-01T06:10:44Z")

</div>

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