# How to reindex using date field in source index?

**URL:** <https://discuss.elastic.co/t/how-to-reindex-using-date-field-in-source-index/189371>\
**Category:** Elasticsearch\
**Created:** [July 8, 2019, 3:23pm UTC](https://discuss.elastic.co/t/how-to-reindex-using-date-field-in-source-index/189371 "2019-07-08T15:23:34Z")\
**Posts on this page:** 7\
**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 8, 2019, 3:23pm UTC](https://discuss.elastic.co/t/how-to-reindex-using-date-field-in-source-index/189371/1 "2019-07-08T15:23:34Z")

</div>

I have a source index with 14 million docs (2.5 TB). Reindexing it all at once is destabilizing the cluster and it stops midway. there is no way of tracking the progress and resuming . So i would like to know how to reindex using a certain date field. For example, i would like to reindex from year 1995 to 1998 in one go and then 1998 to 2001 in another.So that if the process stops at any time , I would be aware of where it stopped and where to resume it from.

> [@Improve reindex speed into new cluster](https://discuss.elastic.co/t/improve-reindex-speed-into-new-cluster/159511/2):
>
> I moved this one to it's own topic. Your request is about reindex speed, but your setup is different so it makes sense to ask questions specifically about it slight_smile

someone talks about something like that in the above topic.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 8, 2019, 3:38pm UTC](https://discuss.elastic.co/t/how-to-reindex-using-date-field-in-source-index/189371/2 "2019-07-08T15:38:12Z")

</div>

The reindex API supports a `query` part. See [https://www.elastic.co/guide/en/elasticsearch/reference/7.2/docs-reindex.html](https://www.elastic.co/guide/en/elasticsearch/reference/7.2/docs-reindex.html)

So if you have a `date` field, you can use a `range` query to select only documents between 2 dates.

---

<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 8, 2019, 4:40pm UTC](https://discuss.elastic.co/t/how-to-reindex-using-date-field-in-source-index/189371/3 "2019-07-08T16:40:50Z")

</div>

Yeah. That seems good. Our index is pretty big. Can i run multiple queries at once . Like one query per year. And how to make sure we got all our documents?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 8, 2019, 5:12pm UTC](https://discuss.elastic.co/t/how-to-reindex-using-date-field-in-source-index/189371/4 "2019-07-08T17:12:45Z")

</div>

I don't know if you can run multiple reindex tasks at the same time.  
To compare what you have in both indices, just count the number of documents in both indices.

---

<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 8, 2019, 5:50pm UTC](https://discuss.elastic.co/t/how-to-reindex-using-date-field-in-source-index/189371/5 "2019-07-08T17:50:03Z")

</div>

FYI. We just tried that. It works. We can run multiple reindex tasks at a time.  
On another note, may i know how "conflicts": "proceed", works in reindex API.

Documentation of reindex API is not clear about it. What it actually treats as conflicts ? etc

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 8, 2019, 7:17pm UTC](https://discuss.elastic.co/t/how-to-reindex-using-date-field-in-source-index/189371/6 "2019-07-08T19:17:02Z")

</div>

If you meant conflicts when several jobs are running in parallel, my guess is that the last change overwrites any previous changes.

---

<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 5, 2019, 7:17pm UTC](https://discuss.elastic.co/t/how-to-reindex-using-date-field-in-source-index/189371/7 "2019-08-05T19:17:09Z")

</div>

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