# How to change routing value for existed routed data?

**URL:** <https://discuss.elastic.co/t/how-to-change-routing-value-for-existed-routed-data/280689>\
**Category:** Elasticsearch\
**Created:** [August 6, 2021, 10:19pm UTC](https://discuss.elastic.co/t/how-to-change-routing-value-for-existed-routed-data/280689 "2021-08-06T22:19:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![judy\_gao](https://avatars.discourse-cdn.com/v4/letter/j/7ab992/32.png) [@judy\_gao](https://discuss.elastic.co/u/judy_gao)\
**Post date:** [August 6, 2021, 10:19pm UTC](https://discuss.elastic.co/t/how-to-change-routing-value-for-existed-routed-data/280689/1 "2021-08-06T22:19:33Z")

</div>

I have an existed index which is "\_routing" required as true. So all data is already routed to particular shards based on "\_routing" value. Right now we're using a customized routing value like "organization id" to route the data. However we have a use case that data could be changed from one organization to another organization. For this use case, we need to update the indexing data for organization id , meanwhile we need to re-route data to another particular shards. We cannot use "Update\_by\_query" , it will show me error like "Modifying \_routing not allowed". Any suggestions for right and easy to approach this , update the data itself and change "\_routing" also . thanks.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [August 7, 2021, 8:16am UTC](https://discuss.elastic.co/t/how-to-change-routing-value-for-existed-routed-data/280689/2 "2021-08-07T08:16:48Z")

</div>

I do not think there is any easy way to do this within Elasticsearch. I suspect you will need to read the data and then delete it before reindexing the updated documents. This will require vide outside Elasticsearch.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [August 7, 2021, 10:41am UTC](https://discuss.elastic.co/t/how-to-change-routing-value-for-existed-routed-data/280689/3 "2021-08-07T10:41:59Z")

</div>

I think that's right. An "update" is really just deleting the old doc and indexing the new one, with a few optimisations that use the fact that the old doc and the new doc are in the same shard. If you're changing the routing then you're potentially moving the doc to a different shard, so those optimisations don't work any more and so it's no different from doing the delete-and-index process yourself.

Update-by-query is just running a search to find the docs and then performing an update on each one in turn: it's also something you can implement yourself.

---

<div class="post-metadata">

**Author:** ![judy\_gao](https://avatars.discourse-cdn.com/v4/letter/j/7ab992/32.png) [@judy\_gao](https://discuss.elastic.co/u/judy_gao)\
**Post date:** [August 7, 2021, 7:13pm UTC](https://discuss.elastic.co/t/how-to-change-routing-value-for-existed-routed-data/280689/4 "2021-08-07T19:13:42Z")

</div>

Thanks David, looks like there is no easy way, I have to do delete-and-index for this. thanks.

---

<div class="post-metadata">

**Author:** ![stevenD](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stevend/32/97934_2.png) [@stevenD](https://discuss.elastic.co/u/stevenD)\
**Post date:** [August 31, 2021, 8:00pm UTC](https://discuss.elastic.co/t/how-to-change-routing-value-for-existed-routed-data/280689/6 "2021-08-31T20:00:56Z")

</div>

An index can be configured such that custom routing values will go to a subset of the shards rather than a single shard. This helps mitigate the risk of ending up with an imbalanced cluster while still reducing the impact of searches. This is done by providing the index level setting index.routing\_partition\_size at index creation

---

<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:** [September 28, 2021, 8:01pm UTC](https://discuss.elastic.co/t/how-to-change-routing-value-for-existed-routed-data/280689/7 "2021-09-28T20:01:07Z")

</div>

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