# How to disable routing in parent and child mapping for Elasticsearch?

**URL:** <https://discuss.elastic.co/t/how-to-disable-routing-in-parent-and-child-mapping-for-elasticsearch/10166>\
**Category:** Elasticsearch\
**Created:** [December 24, 2012, 7:56am UTC](https://discuss.elastic.co/t/how-to-disable-routing-in-parent-and-child-mapping-for-elasticsearch/10166 "2012-12-24T07:56:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan\_Moo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonathan_moo/32/2562_2.png) [@Jonathan\_Moo](https://discuss.elastic.co/u/Jonathan_Moo)\
**Post date:** [December 24, 2012, 7:56am UTC](https://discuss.elastic.co/t/how-to-disable-routing-in-parent-and-child-mapping-for-elasticsearch/10166/1 "2012-12-24T07:56:19Z")

</div>

I have explicitly disabled routing for my Elasticsearch(ES) mapping:

{  
"chow-clfg": {  
"\_parent": {  
"type": "chow-demo"  
},  
"\_routing": {  
"required": false  
},  
"\_id": {  
"path": "clfg"  
},  
"dynamic": "true",  
"\_ttl": {  
"enabled": true,  
"default": "1h"  
},  
"properties": {  
"clfg": {  
"analyzer": "keyword",  
"type": "string"  
},  
"@timestamp": {  
"format": "dateOptionalTime",  
"type": "date"  
},  
"count": {  
"type": "long"  
}  
}  
}  
}

After doing curl command to delete and update the new mapping, I still get  
the routing enabled when I do a \_cluster/state command:

"mappings" : {  
"chow-clfg" : {  
"\_id" : {  
"path" : "clfg"  
},  
"\_routing" : {  
"required" : true  
},  
"\_ttl" : {  
"enabled" : true,  
"default" : 3600000  
},  
"properties" : {  
"@timestamp" : {  
"format" : "dateOptionalTime",  
"type" : "date"  
},  
"clfg" : {  
"analyzer" : "keyword",  
"type" : "string"  
},  
"count" : {  
"type" : "long"  
}  
},  
"\_parent" : {  
"type" : "chow-demo"  
}  
}

So it leaves me with the following questions:

1. How can I disable the routing if it is not a necessary requirement to  
have in a parent/child mapping?
2. If routing is a requirement, can routing be done on a field that is  
not unique?

--

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [December 24, 2012, 1:48pm UTC](https://discuss.elastic.co/t/how-to-disable-routing-in-parent-and-child-mapping-for-elasticsearch/10166/2 "2012-12-24T13:48:53Z")

</div>

1. You can't because parent/child is based on routing.
2. In parent/child, routing is implicitly set to the parent document to  
gather all children in a single shard.

Jörg

--

---

<div class="post-metadata">

**Author:** ![Jonathan\_Moo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonathan_moo/32/2562_2.png) [@Jonathan\_Moo](https://discuss.elastic.co/u/Jonathan_Moo)\
**Post date:** [December 24, 2012, 2:36pm UTC](https://discuss.elastic.co/t/how-to-disable-routing-in-parent-and-child-mapping-for-elasticsearch/10166/3 "2012-12-24T14:36:10Z")

</div>

Thanks Jorg!

If it is implicitly being set to routing, does it mean that I don't have to  
explicitly specify routing? However when I try to index the child document,  
it gives me the routing missing exception error. Is it a bug? Or am I  
supposed to set an explicit routing?

Jonathan

On Monday, 24 December 2012 15:56:19 UTC+8, Jonathan Moo wrote:

> I have explicitly disabled routing for my Elasticsearch(ES) mapping:
> 
> {  
> "chow-clfg": {  
> "\_parent": {  
> "type": "chow-demo"  
> },  
> "\_routing": {  
> "required": false  
> },  
> "\_id": {  
> "path": "clfg"  
> },  
> "dynamic": "true",  
> "\_ttl": {  
> "enabled": true,  
> "default": "1h"  
> },  
> "properties": {  
> "clfg": {  
> "analyzer": "keyword",  
> "type": "string"  
> },  
> "@timestamp": {  
> "format": "dateOptionalTime",  
> "type": "date"  
> },  
> "count": {  
> "type": "long"  
> }  
> }  
> }  
> }
> 
> After doing curl command to delete and update the new mapping, I still get  
> the routing enabled when I do a \_cluster/state command:
> 
> "mappings" : {  
> "chow-clfg" : {  
> "\_id" : {  
> "path" : "clfg"  
> },  
> "\_routing" : {  
> "required" : true  
> },  
> "\_ttl" : {  
> "enabled" : true,  
> "default" : 3600000  
> },  
> "properties" : {  
> "@timestamp" : {  
> "format" : "dateOptionalTime",  
> "type" : "date"  
> },  
> "clfg" : {  
> "analyzer" : "keyword",  
> "type" : "string"  
> },  
> "count" : {  
> "type" : "long"  
> }  
> },  
> "\_parent" : {  
> "type" : "chow-demo"  
> }  
> }
> 
> So it leaves me with the following questions:
> 
> 1. How can I disable the routing if it is not a necessary requirement  
> to have in a parent/child mapping?
> 2. If routing is a requirement, can routing be done on a field that is  
> not unique?

--

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [December 24, 2012, 3:04pm UTC](https://discuss.elastic.co/t/how-to-disable-routing-in-parent-and-child-mapping-for-elasticsearch/10166/4 "2012-12-24T15:04:01Z")

</div>

The routing value is based on the parent value for child documents by  
default, so if you use the `parent` option during indexing no routing  
has to be specified. Can try to create a gist and that shows your  
issue?

On 24 December 2012 15:36, Jonathan Moo [webmusing@gmail.com](mailto:webmusing@gmail.com) wrote:

> Thanks Jorg!
> 
> If it is implicitly being set to routing, does it mean that I don't have to  
> explicitly specify routing? However when I try to index the child document,  
> it gives me the routing missing exception error. Is it a bug? Or am I  
> supposed to set an explicit routing?
> 
> Jonathan
> 
> On Monday, 24 December 2012 15:56:19 UTC+8, Jonathan Moo wrote:
> 
> > I have explicitly disabled routing for my Elasticsearch(ES) mapping:
> > 
> > {  
> > "chow-clfg": {  
> > "\_parent": {  
> > "type": "chow-demo"  
> > },  
> > "\_routing": {  
> > "required": false  
> > },  
> > "\_id": {  
> > "path": "clfg"  
> > },  
> > "dynamic": "true",  
> > "\_ttl": {  
> > "enabled": true,  
> > "default": "1h"  
> > },  
> > "properties": {  
> > "clfg": {  
> > "analyzer": "keyword",  
> > "type": "string"  
> > },  
> > "@timestamp": {  
> > "format": "dateOptionalTime",  
> > "type": "date"  
> > },  
> > "count": {  
> > "type": "long"  
> > }  
> > }  
> > }  
> > }
> > 
> > After doing curl command to delete and update the new mapping, I still get  
> > the routing enabled when I do a \_cluster/state command:
> > 
> > "mappings" : {  
> > "chow-clfg" : {  
> > "\_id" : {  
> > "path" : "clfg"  
> > },  
> > "\_routing" : {  
> > "required" : true  
> > },  
> > "\_ttl" : {  
> > "enabled" : true,  
> > "default" : 3600000  
> > },  
> > "properties" : {  
> > "@timestamp" : {  
> > "format" : "dateOptionalTime",  
> > "type" : "date"  
> > },  
> > "clfg" : {  
> > "analyzer" : "keyword",  
> > "type" : "string"  
> > },  
> > "count" : {  
> > "type" : "long"  
> > }  
> > },  
> > "\_parent" : {  
> > "type" : "chow-demo"  
> > }  
> > }
> > 
> > So it leaves me with the following questions:
> > 
> > How can I disable the routing if it is not a necessary requirement to have  
> > in a parent/child mapping?  
> > If routing is a requirement, can routing be done on a field that is not  
> > unique?
> 
> --

--  
Met vriendelijke groet,

Martijn van Groningen

--

---

<div class="post-metadata">

**Author:** ![Jonathan\_Moo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonathan_moo/32/2562_2.png) [@Jonathan\_Moo](https://discuss.elastic.co/u/Jonathan_Moo)\
**Post date:** [December 24, 2012, 5:40pm UTC](https://discuss.elastic.co/t/how-to-disable-routing-in-parent-and-child-mapping-for-elasticsearch/10166/5 "2012-12-24T17:40:07Z")

</div>

Hi Martijn,  
\*  
\*  
Thanks for your help! I realized I made an error while I was trying to  
index. I have been trying to index this:  
curl -XPUT  
'[http://localhost:9200/prototype\_2012.12.24/chow-clfg/Cg-IKkxdTstKAAAAlw-](http://localhost:9200/prototype_2012.12.24/chow-clfg/Cg-IKkxdTstKAAAAlw-)'  
-d  
'{"clfg":"Cg+IKkxdTstKAAAAlwQ","@timestamp":"2012-12-24T17:25:00.000Z","count":1}'

but this will throw an error here:  
{"error":"RoutingMissingException[routing is required for  
[prototype\_2012.12.24]/[chow-clfg]/[Cg-IKkxdTstKAAAAlw-]]","status":500}

So if I add this:  
curl -XPUT  
'[http://localhost:9200/prototype\_2012.12.24/chow-clfg/Cg-IKkxdTstKAAAAlw-?](http://localhost:9200/prototype_2012.12.24/chow-clfg/Cg-IKkxdTstKAAAAlw-?)\*  
parent=chow-demo\*' -d  
'{"clfg":"Cg+IKkxdTstKAAAAlwQ","@timestamp":"2012-12-24T17:25:00.000Z","count":1}'

Then it will properly index.

My apologies for not getting the syntax correct.

Jonathan

On Monday, 24 December 2012 15:56:19 UTC+8, Jonathan Moo wrote:

> I have explicitly disabled routing for my Elasticsearch(ES) mapping:
> 
> {  
> "chow-clfg": {  
> "\_parent": {  
> "type": "chow-demo"  
> },  
> "\_routing": {  
> "required": false  
> },  
> "\_id": {  
> "path": "clfg"  
> },  
> "dynamic": "true",  
> "\_ttl": {  
> "enabled": true,  
> "default": "1h"  
> },  
> "properties": {  
> "clfg": {  
> "analyzer": "keyword",  
> "type": "string"  
> },  
> "@timestamp": {  
> "format": "dateOptionalTime",  
> "type": "date"  
> },  
> "count": {  
> "type": "long"  
> }  
> }  
> }  
> }
> 
> After doing curl command to delete and update the new mapping, I still get  
> the routing enabled when I do a \_cluster/state command:
> 
> "mappings" : {  
> "chow-clfg" : {  
> "\_id" : {  
> "path" : "clfg"  
> },  
> "\_routing" : {  
> "required" : true  
> },  
> "\_ttl" : {  
> "enabled" : true,  
> "default" : 3600000  
> },  
> "properties" : {  
> "@timestamp" : {  
> "format" : "dateOptionalTime",  
> "type" : "date"  
> },  
> "clfg" : {  
> "analyzer" : "keyword",  
> "type" : "string"  
> },  
> "count" : {  
> "type" : "long"  
> }  
> },  
> "\_parent" : {  
> "type" : "chow-demo"  
> }  
> }
> 
> So it leaves me with the following questions:
> 
> 1. How can I disable the routing if it is not a necessary requirement  
> to have in a parent/child mapping?
> 2. If routing is a requirement, can routing be done on a field that is  
> not unique?

--

---

<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, 2:58am UTC](https://discuss.elastic.co/t/how-to-disable-routing-in-parent-and-child-mapping-for-elasticsearch/10166/6 "2017-07-06T02:58:33Z")

</div>


