# How to copy data of one specific shard (indices A) to another indices (indices B)?

**URL:** <https://discuss.elastic.co/t/how-to-copy-data-of-one-specific-shard-indices-a-to-another-indices-indices-b/177170>\
**Category:** Elasticsearch\
**Created:** [April 16, 2019, 11:45pm UTC](https://discuss.elastic.co/t/how-to-copy-data-of-one-specific-shard-indices-a-to-another-indices-indices-b/177170 "2019-04-16T23:45:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mario12](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mario12/32/29324_2.png) [@mario12](https://discuss.elastic.co/u/mario12)\
**Post date:** [April 16, 2019, 11:45pm UTC](https://discuss.elastic.co/t/how-to-copy-data-of-one-specific-shard-indices-a-to-another-indices-indices-b/177170/1 "2019-04-16T23:45:10Z")

</div>

I have to copy data of one specific shard (indices A) to another indices (indices B). How can this be done?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 16, 2019, 11:53pm UTC](https://discuss.elastic.co/t/how-to-copy-data-of-one-specific-shard-indices-a-to-another-indices-indices-b/177170/2 "2019-04-16T23:53:06Z")

</div>

I don't believe you can extract it from one particular shard like that, unless you are using routing?

---

<div class="post-metadata">

**Author:** ![mario12](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mario12/32/29324_2.png) [@mario12](https://discuss.elastic.co/u/mario12)\
**Post date:** [April 16, 2019, 11:54pm UTC](https://discuss.elastic.co/t/how-to-copy-data-of-one-specific-shard-indices-a-to-another-indices-indices-b/177170/3 "2019-04-16T23:54:57Z")

</div>

Can I re-index the data using a query to search for a specific shard from Indices A and insert it into Indices B?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 16, 2019, 11:55pm UTC](https://discuss.elastic.co/t/how-to-copy-data-of-one-specific-shard-indices-a-to-another-indices-indices-b/177170/4 "2019-04-16T23:55:18Z")

</div>

Not unless you are using routing.

---

<div class="post-metadata">

**Author:** ![mario12](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mario12/32/29324_2.png) [@mario12](https://discuss.elastic.co/u/mario12)\
**Post date:** [April 16, 2019, 11:57pm UTC](https://discuss.elastic.co/t/how-to-copy-data-of-one-specific-shard-indices-a-to-another-indices-indices-b/177170/5 "2019-04-16T23:57:14Z")

</div>

The size of each shard varies. I think we route data to specific shards.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 16, 2019, 11:57pm UTC](https://discuss.elastic.co/t/how-to-copy-data-of-one-specific-shard-indices-a-to-another-indices-indices-b/177170/6 "2019-04-16T23:57:54Z")

</div>

If you know the routing keys used you might be able to do it that way.

---

<div class="post-metadata">

**Author:** ![mario12](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mario12/32/29324_2.png) [@mario12](https://discuss.elastic.co/u/mario12)\
**Post date:** [April 17, 2019, 12:00am UTC](https://discuss.elastic.co/t/how-to-copy-data-of-one-specific-shard-indices-a-to-another-indices-indices-b/177170/7 "2019-04-17T00:00:20Z")

</div>

As a test I can re-index by querying the source by shard id and verify if the data is going to the intended destination shard. @warkolm can you please let me know your opinion?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 17, 2019, 12:24am UTC](https://discuss.elastic.co/t/how-to-copy-data-of-one-specific-shard-indices-a-to-another-indices-indices-b/177170/8 "2019-04-17T00:24:09Z")

</div>

There is no such thing as a query by shard ID. The closest you would get would be to query by the routing key.

---

<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 15, 2019, 12:24am UTC](https://discuss.elastic.co/t/how-to-copy-data-of-one-specific-shard-indices-a-to-another-indices-indices-b/177170/9 "2019-05-15T00:24:10Z")

</div>

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