# Multiple Field as mapping iD

**URL:** <https://discuss.elastic.co/t/multiple-field-as-mapping-id/135103>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [June 8, 2018, 7:53am UTC](https://discuss.elastic.co/t/multiple-field-as-mapping-id/135103 "2018-06-08T07:53:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![padhu1989](https://avatars.discourse-cdn.com/v4/letter/p/cc9497/32.png) [@padhu1989](https://discuss.elastic.co/u/padhu1989)\
**Post date:** [June 8, 2018, 7:53am UTC](https://discuss.elastic.co/t/multiple-field-as-mapping-id/135103/1 "2018-06-08T07:53:27Z")

</div>

I am pretty new to elastic search. I am using elasticsearch-hadoop 6.2.4 version and I am reading the files from HDFS, converting to bean object and writing to elastic search. I am using Spark Structured streaming.

```
    StreamingQuery query = dataSet
                    .writeStream()
                    .format("org.elasticsearch.spark.sql")
                    //.outputMode(OutputMode.Append())
                    .option("checkpointLocation", "\tmp\ckpt1")
                    .option("es.nodes","abc.dev.cm.par.xy.hp")
                    .option("es.port","9200")
                    .option("es.mapping.id", "CustomerID")
                    .option("es.resource", "testIndex/testType")
                    .start();

```

While writing i am giving one of the field (CustomerID)in the pojo class as mapping iD. Can we give multiple fields or combination of fields as mapping ID? For example, my file contains customer id as well as order id fields. Can we combine these both fields as CustomerID+Order ID something like that?

---

<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:** [June 21, 2018, 3:20pm UTC](https://discuss.elastic.co/t/multiple-field-as-mapping-id/135103/2 "2018-06-21T15:20:42Z")

</div>

If you create a new id field during your spark processing, you can reference that id field in the `es.mapping.id` setting. Granted, this will write out this id field to Elasticsearch, so if you do not want the field to be ignored after the id is extracted, you can include its name under `es.mapping.exclude`

---

<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 19, 2018, 3:21pm UTC](https://discuss.elastic.co/t/multiple-field-as-mapping-id/135103/3 "2018-07-19T15:21:01Z")

</div>

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