# How to update documents using spark

**URL:** <https://discuss.elastic.co/t/how-to-update-documents-using-spark/65833>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [November 11, 2016, 5:47pm UTC](https://discuss.elastic.co/t/how-to-update-documents-using-spark/65833 "2016-11-11T17:47:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![saisn](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@saisn](https://discuss.elastic.co/u/saisn)\
**Post date:** [November 11, 2016, 5:47pm UTC](https://discuss.elastic.co/t/how-to-update-documents-using-spark/65833/1 "2016-11-11T17:47:41Z")

</div>

How can i update documents in an index using document\_id in spark. I've seen the option called [es.mappings.id](http://es.mappings.id) but can it be used with multiple fields.

For eg:

I had two fields userid,serialno and i want to create document\_id as %{userid}%{serialno} in spark.

Thanks

---

<div class="post-metadata">

**Author:** ![saisn](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@saisn](https://discuss.elastic.co/u/saisn)\
**Post date:** [November 12, 2016, 6:07pm UTC](https://discuss.elastic.co/t/how-to-update-documents-using-spark/65833/2 "2016-11-12T18:07:06Z")

</div>

I'm able to do for one column using [es.mapping.id](http://es.mapping.id). Can someone tell me how i can include two or more columns as document id

df.write.format("org.elasticsearch.spark.sql").option("[es.mapping.id](http://es.mapping.id)","userid").option("es.resource","testindex/abc").save()

---

<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:** [December 10, 2016, 6:07pm UTC](https://discuss.elastic.co/t/how-to-update-documents-using-spark/65833/3 "2016-12-10T18:07:10Z")

</div>

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