# Routing with path

**URL:** <https://discuss.elastic.co/t/routing-with-path/8179>\
**Category:** Elasticsearch\
**Created:** [June 21, 2012, 11:16am UTC](https://discuss.elastic.co/t/routing-with-path/8179 "2012-06-21T11:16:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ngocvo3103](https://avatars.discourse-cdn.com/v4/letter/n/aca169/32.png) [@ngocvo3103](https://discuss.elastic.co/u/ngocvo3103)\
**Post date:** [June 21, 2012, 11:16am UTC](https://discuss.elastic.co/t/routing-with-path/8179/1 "2012-06-21T11:16:50Z")

</div>

Hi all,

I followed the guide here : [http://www.elasticsearch.org/guide/reference/mapping/routing-field.html](http://www.elasticsearch.org/guide/reference/mapping/routing-field.html) and successfully created my own index

However, when I try to insert a document into the index, I got this error message "**MapperParsingException[External routing [sammy] and document path routing [null] mismatch]**". I've tried everything to make it work but there's still no hope . Could you please take a look in my requests for the APIs and give me some advice?

# CREATE INDEX

# { "settings":{ "index":{ "number\_of\_shards" : 10, "number\_of\_replicas": 1 } }, "mappings":{ "user":{ "\_source" : {"enabled" : false}, "\_routing": { "required" : true, "path" : "user.username" }, "properties":{ "name" : { "type" : "object", "properties" : { "first\_name" : {"type": "string"}, "last\_name" : {"type": "string"} } }, "username" : {"type" : "string", "boost" : 1.2}, "email": {"type": "string"} } }, "item":{ "\_source" : {"enabled" : false}, "\_parent" : { "type" : "user"}, "\_routing" : { "required" : true, "path" : "item.owner" }, "\_timestamp" : { "enabled" : true, "format" : "MM-dd-yyyy hh:mm:ss" }, "\_ttl" : {"enabled" : true, "default" : "3d"}, "properties":{ "id" : {"type" : "string", "path" : "item.\_timestamp"}, "name": {"type": "string", "boost" : 1.4}, "price": {"type": "float"}, "type" : {"type": "string"}, "postDate" : {"type" : "date", "format" : "MM-dd-yyyy"}, "owner" : {"type": "string", "boost" : 1.2}, "message" : {"type" : "string", "index" : "analyzed", "null\_value" : "na"} } } } }

# INSERT DOCUMENT

# curl -XPUT '[http://localhost:9200/ecommerce/user?routing=sammy&pretty=true](http://localhost:9200/ecommerce/user?routing=sammy&pretty=true) -d '{ "name" : { "first\_name": "sam", "last\_name" : "Vo" }, "username" : "sammy", "email" : "sammy@abc.com" }

Regards,  
Sam Vo

---

<div class="post-metadata">

**Author:** ![ngocvo3103](https://avatars.discourse-cdn.com/v4/letter/n/aca169/32.png) [@ngocvo3103](https://discuss.elastic.co/u/ngocvo3103)\
**Post date:** [June 22, 2012, 3:32am UTC](https://discuss.elastic.co/t/routing-with-path/8179/2 "2012-06-22T03:32:18Z")

</div>

Hi all,

I've found my own solution for this :). It's because my mapping was not right. it should be some thing like this:

"mappings":{   
"user":{  
"\_source" : {"enabled" : false},  
"\_routing": {  
"required" : true,   
"path" : "username"  
},  
"properties":{  
"name" : {  
"type" : "object",  
"properties" : {  
"first\_name" : {"type": "string"},  
"last\_name" : {"type": "string"}   
}  
},  
"username" : {"type" : "string", "boost" : 1.2, "store" : "yes"},  
"email": {"type": "string"}  
}  
}

Elastic Search is interesting 🙂

Regards,

Sam Vo

---

<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:22am UTC](https://discuss.elastic.co/t/routing-with-path/8179/3 "2017-07-06T03:22:59Z")

</div>


