# Reindex from multiple indices to a new one \_with\_new\_document\_ID's\_!

**URL:** <https://discuss.elastic.co/t/reindex-from-multiple-indices-to-a-new-one--with-new-document-ids-/83743>\
**Category:** Elasticsearch\
**Created:** [April 26, 2017, 5:39pm UTC](https://discuss.elastic.co/t/reindex-from-multiple-indices-to-a-new-one--with-new-document-ids-/83743 "2017-04-26T17:39:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dennis.dyall](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@dennis.dyall](https://discuss.elastic.co/u/dennis.dyall)\
**Post date:** [April 26, 2017, 5:39pm UTC](https://discuss.elastic.co/t/reindex-from-multiple-indices-to-a-new-one--with-new-document-ids-/83743/1 "2017-04-26T17:39:57Z")

</div>

Hi! I tried \_reindex to reindex logs-2016-11.\* to logs-2016-11.

I expected about 9 000 000 docs to be in the resulting index.  
Then I did a \_cat/indices/logs-2016-11?v  
And I see that the index contains about half of the documents, and the other half seem to be represented in the 'docs.deleted' column.  
I assume this is because clashing ID's. Also when I inspected the reindex task, I saw a lot of docs were being deleted and only a few created.

So does this mean that the daily indices in logs-2016-11-\* can have clashing ID's and therefor the reindex operation is just updating documents with the same ID?

In that case - how do I tell Elasticsearch to reindex them but with new ID's?  
I tried:

> ```
> {
> "size": 10,
> "source": {
> "index": ["logs-2016-11-*"],
> "_source": [<list of properties I want to keep EXCLUDING _id>]
> },
> "dest": {
> "index": "tesssssst"
> }
> }
> 
> ```

And I also tried to use a script:

script: "ctx.source.\_id = null"

Then I got a null pointer exception.

Please advise!

---

<div class="post-metadata">

**Author:** ![dennis.dyall](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@dennis.dyall](https://discuss.elastic.co/u/dennis.dyall)\
**Post date:** [April 27, 2017, 9:10am UTC](https://discuss.elastic.co/t/reindex-from-multiple-indices-to-a-new-one--with-new-document-ids-/83743/2 "2017-04-27T09:10:59Z")

</div>

I think I solved this by using

> ctx.\_id = null

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [April 27, 2017, 2:35pm UTC](https://discuss.elastic.co/t/reindex-from-multiple-indices-to-a-new-one--with-new-document-ids-/83743/3 "2017-04-27T14:35:06Z")

</div>

`ctx._id = ctx._index + ':' + ctx._id` might also work if you need to preserve the ids.

---

<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:** [May 25, 2017, 2:46pm UTC](https://discuss.elastic.co/t/reindex-from-multiple-indices-to-a-new-one--with-new-document-ids-/83743/4 "2017-05-25T14:46:10Z")

</div>

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