# External routing and document path routing mismatch

**URL:** <https://discuss.elastic.co/t/external-routing-and-document-path-routing-mismatch/5323>\
**Category:** Elasticsearch\
**Created:** [September 7, 2011, 1:39pm UTC](https://discuss.elastic.co/t/external-routing-and-document-path-routing-mismatch/5323 "2011-09-07T13:39:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frederic](https://avatars.discourse-cdn.com/v4/letter/f/4491bb/32.png) [@Frederic](https://discuss.elastic.co/u/Frederic)\
**Post date:** [September 7, 2011, 1:39pm UTC](https://discuss.elastic.co/t/external-routing-and-document-path-routing-mismatch/5323/1 "2011-09-07T13:39:47Z")

</div>

Hi people,

I need you help to know what I'm doing wrong in this really simple  
scenario, that I need to extrapolate afterwards to a rather big system  
(about 50M docs in 20 shards).

I've configured the routing of documents on the server side, creating  
the index and defining the mapping of an "Item" type as follows (based  
on [http://www.elasticsearch.org/guide/reference/mapping/routing-field.html](http://www.elasticsearch.org/guide/reference/mapping/routing-field.html))

$ curl -XPUT '[http://localhost:9200/items/](http://localhost:9200/items/)' -d '{  
"settings" : {  
"index" : { "number\_of\_shards" : 2, "number\_of\_replicas" :  
1 }  
},  
"mappings" : {  
"item" : {  
"\_routing" : {  
"required" : true,  
"path" : "seller\_id"  
}  
}  
}  
}'

But when I try to index an item, with the following request,  
$curl -XPUT [http://localhost:9200/items/item/123](http://localhost:9200/items/item/123) -d  
'{"id":"123","title":"A title","seller\_id":19875421}'

I get the error  
{"error":"MapperParsingException[External routing [19875421] and  
document path routing [null] mismatch]","status":400}

Any ideas of what am I doing wrong? I've walkedt through part of the  
code of ES, following the exception stack trace, but couldn't figure  
out the origin of the problem.

Server stack trace:  
org.elasticsearch.index.mapper.MapperParsingException: External  
routing [19875421] and document path routing [null] mismatch  
at  
org.elasticsearch.index.mapper.internal.RoutingFieldMapper.validate(RoutingFieldMapper.java:  
137)  
at  
org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:  
611)  
at  
org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:  
491)  
at  
org.elasticsearch.index.shard.service.InternalIndexShard.prepareIndex(InternalIndexShard.java:  
289)  
at  
org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:  
185)  
at  
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction  
$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:  
428)  
at  
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction  
$AsyncShardOperationAction  
$1.run(TransportShardReplicationOperationAction.java:341)  
....

Thanks in advance,  
Frederic

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [September 7, 2011, 2:30pm UTC](https://discuss.elastic.co/t/external-routing-and-document-path-routing-mismatch/5323/2 "2011-09-07T14:30:17Z")

</div>

it happens because the seller\_id is a numeric value (and indexed  
differently...). If you change it to be a string, it will work. You can open  
an issue to fix it...

On Wed, Sep 7, 2011 at 4:39 PM, Frederic [focampo.br@gmail.com](mailto:focampo.br@gmail.com) wrote:

> Hi people,
> 
> I need you help to know what I'm doing wrong in this really simple  
> scenario, that I need to extrapolate afterwards to a rather big system  
> (about 50M docs in 20 shards).
> 
> I've configured the routing of documents on the server side, creating  
> the index and defining the mapping of an "Item" type as follows (based  
> on [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/routing-field.html)  
> )
> 
> $ curl -XPUT '[http://localhost:9200/items/](http://localhost:9200/items/)' -d '{  
> "settings" : {  
> "index" : { "number\_of\_shards" : 2, "number\_of\_replicas" :  
> 1 }  
> },  
> "mappings" : {  
> "item" : {  
> "\_routing" : {  
> "required" : true,  
> "path" : "seller\_id"  
> }  
> }  
> }  
> }'
> 
> But when I try to index an item, with the following request,  
> $curl -XPUT [http://localhost:9200/items/item/123](http://localhost:9200/items/item/123) -d  
> '{"id":"123","title":"A title","seller\_id":19875421}'
> 
> I get the error  
> {"error":"MapperParsingException[External routing [19875421] and  
> document path routing [null] mismatch]","status":400}
> 
> Any ideas of what am I doing wrong? I've walkedt through part of the  
> code of ES, following the exception stack trace, but couldn't figure  
> out the origin of the problem.
> 
> Server stack trace:  
> org.elasticsearch.index.mapper.MapperParsingException: External  
> routing [19875421] and document path routing [null] mismatch  
> at
> 
> org.elasticsearch.index.mapper.internal.RoutingFieldMapper.validate(RoutingFieldMapper.java:  
> 137)  
> at  
> org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:  
> 611)  
> at  
> org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:  
> 491)  
> at
> 
> org.elasticsearch.index.shard.service.InternalIndexShard.prepareIndex(InternalIndexShard.java:  
> 289)  
> at
> 
> org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:  
> 185)  
> at
> 
> org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction
> 
> $AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:  
> 428)  
> at
> 
> org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction  
> $AsyncShardOperationAction  
> $1.run(TransportShardReplicationOperationAction.java:341)  
> ....
> 
> Thanks in advance,  
> Frederic

---

<div class="post-metadata">

**Author:** ![Frederic](https://avatars.discourse-cdn.com/v4/letter/f/4491bb/32.png) [@Frederic](https://discuss.elastic.co/u/Frederic)\
**Post date:** [September 7, 2011, 2:42pm UTC](https://discuss.elastic.co/t/external-routing-and-document-path-routing-mismatch/5323/3 "2011-09-07T14:42:10Z")

</div>

Thanks a lot for your quick answer Kimchy.  
I'll open the issue then, and try to index the value as string  
meanwhile.

On 7 sep, 11:30, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> it happens because the seller\_id is a numeric value (and indexed  
> differently...). If you change it to be a string, it will work. You can open  
> an issue to fix it...
> 
> On Wed, Sep 7, 2011 at 4:39 PM, Frederic [focampo...@gmail.com](mailto:focampo...@gmail.com) wrote:
> 
> > Hi people,
> 
> > I need you help to know what I'm doing wrong in this really simple  
> > scenario, that I need to extrapolate afterwards to a rather big system  
> > (about 50M docs in 20 shards).
> 
> > I've configured the routing of documents on the server side, creating  
> > the index and defining the mapping of an "Item" type as follows (based  
> > onhttp://www.elasticsearch.org/guide/reference/mapping/routing-field.html  
> > )
> 
> > $ curl -XPUT '[http://localhost:9200/items/'-d](http://localhost:9200/items/'-d) '{  
> > "settings" : {  
> > "index" : { "number\_of\_shards" : 2, "number\_of\_replicas" :  
> > 1 }  
> > },  
> > "mappings" : {  
> > "item" : {  
> > "\_routing" : {  
> > "required" : true,  
> > "path" : "seller\_id"  
> > }  
> > }  
> > }  
> > }'
> 
> > But when I try to index an item, with the following request,  
> > $curl -XPUThttp://localhost:9200/items/item/123-d  
> > '{"id":"123","title":"A title","seller\_id":19875421}'
> 
> > I get the error  
> > {"error":"MapperParsingException[External routing [19875421] and  
> > document path routing [null] mismatch]","status":400}
> 
> > Any ideas of what am I doing wrong? I've walkedt through part of the  
> > code of ES, following the exception stack trace, but couldn't figure  
> > out the origin of the problem.
> 
> > Server stack trace:  
> > org.elasticsearch.index.mapper.MapperParsingException: External  
> > routing [19875421] and document path routing [null] mismatch  
> > at
> 
> > org.elasticsearch.index.mapper.internal.RoutingFieldMapper.validate(RoutingFieldMapper.java:  
> > 137)  
> > at  
> > org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:  
> > 611)  
> > at  
> > org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:  
> > 491)  
> > at
> 
> > org.elasticsearch.index.shard.service.InternalIndexShard.prepareIndex(InternalIndexShard.java:  
> > 289)  
> > at
> 
> > org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:  
> > 185)  
> > at
> 
> > org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction
> 
> > $AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:  
> > 428)  
> > at
> 
> > org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction  
> > $AsyncShardOperationAction  
> > $1.run(TransportShardReplicationOperationAction.java:341)  
> > ....
> 
> > Thanks in advance,  
> > Frederic

---

<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:55am UTC](https://discuss.elastic.co/t/external-routing-and-document-path-routing-mismatch/5323/4 "2017-07-06T03:55:04Z")

</div>


