# Moving all shards in an index to the same node

**URL:** https://discuss.elastic.co/t/moving-all-shards-in-an-index-to-the-same-node/330956
**Category:** Elasticsearch
**Created:** [April 27, 2023, 1:31pm UTC](https://discuss.elastic.co/t/moving-all-shards-in-an-index-to-the-same-node/330956 "2023-04-27T13:31:13Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![andrew3](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@andrew3](https://discuss.elastic.co/u/andrew3)
#### Post date: [April 27, 2023, 1:31pm UTC](https://discuss.elastic.co/t/moving-all-shards-in-an-index-to-the-same-node/330956/1 "2023-04-27T13:31:13Z")

</div>

We want to implement the shrink index API on our cluster. A pre-requisite is that all shards in the to-be-shrunk index must reside on the same node. Currently, this is not the case.

What is the simplest way to move all shards in an index to the same node?

Thanks!

---

<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 30, 2023, 11:11pm UTC](https://discuss.elastic.co/t/moving-all-shards-in-an-index-to-the-same-node/330956/2 "2023-04-30T23:11:03Z")

</div>

Welcome to our community! 😃

[Index-level shard allocation filtering | Elasticsearch Guide [8.7] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/8.7/shard-allocation-filtering.html) and use `index.routing.allocation.require.ip` and then add in the IP of the host (or use `hostname`).

However if you issue a shrink request, Elasticsearch should handle the re-allocation for you.

---

<div class="post-metadata">

### Author: ![achalk](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@achalk](https://discuss.elastic.co/u/achalk)
#### Post date: [May 1, 2023, 1:06pm UTC](https://discuss.elastic.co/t/moving-all-shards-in-an-index-to-the-same-node/330956/3 "2023-05-01T13:06:59Z")

</div>

Thanks. And it is dynamic!

---

<div class="post-metadata">

### Author: ![andrew3](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@andrew3](https://discuss.elastic.co/u/andrew3)
#### Post date: [May 1, 2023, 3:43pm UTC](https://discuss.elastic.co/t/moving-all-shards-in-an-index-to-the-same-node/330956/5 "2023-05-01T15:43:18Z")

</div>

> [@warkolm](#):
>
> However if you issue a shrink request, Elasticsearch should handle the re-allocation for you.

In the v7.17 docs. the shards all residing on the same node is stated as as a prerequisite, not something that "Elasticsearch will handle for you". I am about to create a task to create this prerequisite. Should I not do so?

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: [May 29, 2023, 3:43pm UTC](https://discuss.elastic.co/t/moving-all-shards-in-an-index-to-the-same-node/330956/6 "2023-05-29T15:43:29Z")

</div>

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