# Routing documents dynamically from spark connector

**URL:** <https://discuss.elastic.co/t/routing-documents-dynamically-from-spark-connector/139247>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [July 9, 2018, 11:45pm UTC](https://discuss.elastic.co/t/routing-documents-dynamically-from-spark-connector/139247 "2018-07-09T23:45:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rkalluri](https://avatars.discourse-cdn.com/v4/letter/r/fbc32d/32.png) [@rkalluri](https://discuss.elastic.co/u/rkalluri)\
**Post date:** [July 9, 2018, 11:45pm UTC](https://discuss.elastic.co/t/routing-documents-dynamically-from-spark-connector/139247/1 "2018-07-09T23:45:44Z")

</div>

I want to be able to do some thing like.

PUT my\_index/\_doc/1?routing=user1&refresh=true  
{  
"title": "This is a document"  
}

As described in [https://www.elastic.co/guide/en/elasticsearch/reference/6.2/mapping-routing-field.html#mapping-routing-field](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/mapping-routing-field.html#mapping-routing-field).

Does the connector support it. So I may have a dataframe with 10000 documents and they might belong to 4 distinct users and I want to route the related docs to a shard/shards.

---

<div class="post-metadata">

**Author:** ![james.baiera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james.baiera/32/10209_2.png) [@james.baiera](https://discuss.elastic.co/u/james.baiera)\
**Post date:** [July 25, 2018, 2:47pm UTC](https://discuss.elastic.co/t/routing-documents-dynamically-from-spark-connector/139247/2 "2018-07-25T14:47:18Z")

</div>

You can specify the routing on a per document basis by referencing the field to extract the routing information from via the `es.mapping.routing` setting: [https://www.elastic.co/guide/en/elasticsearch/hadoop/current/configuration.html#cfg-mapping](https://www.elastic.co/guide/en/elasticsearch/hadoop/current/configuration.html#cfg-mapping)

---

<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:** [August 22, 2018, 2:59pm UTC](https://discuss.elastic.co/t/routing-documents-dynamically-from-spark-connector/139247/3 "2018-08-22T14:59:23Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
