# Reindexing docs that don’t yet exist in new index only (by doc id)

**URL:** <https://discuss.elastic.co/t/reindexing-docs-that-don-t-yet-exist-in-new-index-only-by-doc-id/240761>\
**Category:** Elasticsearch\
**Created:** [July 10, 2020, 8:32pm UTC](https://discuss.elastic.co/t/reindexing-docs-that-don-t-yet-exist-in-new-index-only-by-doc-id/240761 "2020-07-10T20:32:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![smlbiobot](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/smlbiobot/32/29622_2.png) [@smlbiobot](https://discuss.elastic.co/u/smlbiobot)\
**Post date:** [July 10, 2020, 8:32pm UTC](https://discuss.elastic.co/t/reindexing-docs-that-don-t-yet-exist-in-new-index-only-by-doc-id/240761/1 "2020-07-10T20:32:36Z")

</div>

I need to reindex some indices so that it will change some object mapping to nested. I plan on setting the doc IDs to be the same in the source index and destination index. The challenge is that the source indices will continue to be written to, so I am trying to see if it’s possible to only index documents that don’t exist in the destination.

One way that I thought of doing is adding a flag on the source docs once the reindex is done, and then use this flag in subsequent reindex as a query to filter the docs that had already been reindexed previously.

I would like to know if there is a simpler way to handle this that I am unaware of, including potentially a simple script that check for existence of a doc id in the destination index to skip the doc.

---

<div class="post-metadata">

**Author:** ![wangqinghuan](https://avatars.discourse-cdn.com/v4/letter/w/d26b3c/32.png) [@wangqinghuan](https://discuss.elastic.co/u/wangqinghuan)\
**Post date:** [July 13, 2020, 1:15am UTC](https://discuss.elastic.co/t/reindexing-docs-that-don-t-yet-exist-in-new-index-only-by-doc-id/240761/2 "2020-07-13T01:15:30Z")

</div>

If you have a time field that flag the create time in your docment, you can filter the incremental document by this time field.

---

<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 10, 2020, 1:15am UTC](https://discuss.elastic.co/t/reindexing-docs-that-don-t-yet-exist-in-new-index-only-by-doc-id/240761/3 "2020-08-10T01:15:30Z")

</div>

Closed on August 10, 2020, 1:15am UTC

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