| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 | [[mapping-routing-field]]=== `_routing`The routing field allows to control the `_routing` aspect when indexingdata and explicit routing control is required.[float]==== store / indexThe first thing the `_routing` mapping does is to store the routingvalue provided (`store` set to `false`) and index it (`index` set to`not_analyzed`). The reason why the routing is stored by default is soreindexing data will be possible if the routing value is completelyexternal and not part of the docs.[float]==== requiredAnother aspect of the `_routing` mapping is the ability to define it asrequired by setting `required` to `true`. This is very important to setwhen using routing features, as it allows different APIs to make use ofit. For example, an index operation will be rejected if no routing valuehas been provided (or derived from the doc). A delete operation will bebroadcasted to all shards if no routing value is provided and `_routing`is required.[float]==== pathThe routing value can be provided as an external value when indexing(and still stored as part of the document, in much the same way`_source` is stored). But, it can also be automatically extracted fromthe index doc based on a `path`. For example, having the followingmapping:[source,js]--------------------------------------------------{    "comment" : {        "_routing" : {            "required" : true,            "path" : "blog.post_id"        }    }}--------------------------------------------------Will cause the following doc to be routed based on the `111222` value:[source,js]--------------------------------------------------{    "text" : "the comment text"    "blog" : {        "post_id" : "111222"    }}--------------------------------------------------Note, using `path` without explicit routing value provided required anadditional (though quite fast) parsing phase.[float]==== id uniquenessWhen indexing documents specifying a custom `_routing`, the uniquenessof the `_id` is not guaranteed throughout all the shards that the indexis composed of. In fact, documents with the same `_id` might end up indifferent shards if indexed with different `_routing` values.
 |