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

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?

--

  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

--

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?

--

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 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

--

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-'
-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-?*
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?

--