# Reindex api using a query and size

**URL:** <https://discuss.elastic.co/t/reindex-api-using-a-query-and-size/51481>\
**Category:** Elasticsearch\
**Created:** [May 31, 2016, 8:11pm UTC](https://discuss.elastic.co/t/reindex-api-using-a-query-and-size/51481 "2016-05-31T20:11:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![marinoc](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@marinoc](https://discuss.elastic.co/u/marinoc)\
**Post date:** [May 31, 2016, 8:11pm UTC](https://discuss.elastic.co/t/reindex-api-using-a-query-and-size/51481/1 "2016-05-31T20:11:28Z")

</div>

I have an index w 120 mil records (each record ~ 5k), and I want to use the Reindex api to create a new index w a subset of those records.

I've identified a subset of records (about 2 million) from a query and would like to use this query in the Reindex api call.

Is it best practice to move all records in a single command, or do I need to do some type of batching or throttling? I know there's a size parameter w the reindex api. If I set it to 10,000, will it move all 2 million records to the new index in batches of 10,000? Or just the first 10,000 records?

Thanks!

---

<div class="post-metadata">

**Author:** ![dakrone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dakrone/32/23351_2.png) [@dakrone](https://discuss.elastic.co/u/dakrone)\
**Post date:** [May 31, 2016, 8:54pm UTC](https://discuss.elastic.co/t/reindex-api-using-a-query-and-size/51481/2 "2016-05-31T20:54:47Z")

</div>

So you certainly can do the entire thing with a single request, however, if you want to have throttling (to lessen the impact of the reindexing), you will have to wait until 2.4.0 (see: [https://github.com/elastic/elasticsearch/pull/18020](https://github.com/elastic/elasticsearch/pull/18020)).

You could do a subset with `size`, but there isn't an offset/from option, so you wouldn't be able to do a different "batch" of documents, you'd have to limit it artificially using the query somehow.

---

<div class="post-metadata">

**Author:** ![marinoc](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@marinoc](https://discuss.elastic.co/u/marinoc)\
**Post date:** [May 31, 2016, 9:05pm UTC](https://discuss.elastic.co/t/reindex-api-using-a-query-and-size/51481/3 "2016-05-31T21:05:33Z")

</div>

Thanks!

---

<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:** [July 5, 2017, 10:47pm UTC](https://discuss.elastic.co/t/reindex-api-using-a-query-and-size/51481/4 "2017-07-05T22:47:31Z")

</div>


