# New document version with different custom routing

**URL:** <https://discuss.elastic.co/t/new-document-version-with-different-custom-routing/9227>\
**Category:** Elasticsearch\
**Created:** [October 3, 2012, 2:36pm UTC](https://discuss.elastic.co/t/new-document-version-with-different-custom-routing/9227 "2012-10-03T14:36:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreas\_chatzakis](https://avatars.discourse-cdn.com/v4/letter/a/58956e/32.png) [@andreas\_chatzakis](https://discuss.elastic.co/u/andreas_chatzakis)\
**Post date:** [October 3, 2012, 2:36pm UTC](https://discuss.elastic.co/t/new-document-version-with-different-custom-routing/9227/1 "2012-10-03T14:36:21Z")

</div>

Hi,

On the situation where a new version of a document comes with a new value  
for its custom routing parameter, we end up with 2 versions of the same  
document id maintained on 2 different shards.

what is the best practice here?

First deleting the document instead of just updating it? Or is there a more  
elegant way to achieve the same via the API?

thanks in advance

--

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [October 3, 2012, 2:39pm UTC](https://discuss.elastic.co/t/new-document-version-with-different-custom-routing/9227/2 "2012-10-03T14:39:40Z")

</div>

Hiya

> On the situation where a new version of a document comes with a new  
> value for its custom routing parameter, we end up with 2 versions of  
> the same document id maintained on 2 different shards.
> 
> what is the best practice here?
> 
> First deleting the document instead of just updating it? Or is there a  
> more elegant way to achieve the same via the API?

I'm afraid you have to delete it with the original routing value before  
indexing it with the new value. ES only checks the shard that it thinks  
the doc is on, so if the routing value has changed, it won't know about  
the existing version.

clint

> thanks in advance
> 
> --

--

---

<div class="post-metadata">

**Author:** ![andreas\_chatzakis](https://avatars.discourse-cdn.com/v4/letter/a/58956e/32.png) [@andreas\_chatzakis](https://discuss.elastic.co/u/andreas_chatzakis)\
**Post date:** [October 4, 2012, 9:09am UTC](https://discuss.elastic.co/t/new-document-version-with-different-custom-routing/9227/3 "2012-10-04T09:09:46Z")

</div>

thanks for confirming our approach

much appreciated

Andreas

On Wednesday, October 3, 2012 5:36:22 PM UTC+3, andreas.chatzakis wrote:

> Hi,
> 
> On the situation where a new version of a document comes with a new value  
> for its custom routing parameter, we end up with 2 versions of the same  
> document id maintained on 2 different shards.
> 
> what is the best practice here?
> 
> First deleting the document instead of just updating it? Or is there a  
> more elegant way to achieve the same via the API?
> 
> thanks in advance

--

---

<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 6, 2017, 3:10am UTC](https://discuss.elastic.co/t/new-document-version-with-different-custom-routing/9227/4 "2017-07-06T03:10:11Z")

</div>


