# Elasticsearch on Spark - Index Mapping

**URL:** <https://discuss.elastic.co/t/elasticsearch-on-spark-index-mapping/27336>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [August 13, 2015, 2:54pm UTC](https://discuss.elastic.co/t/elasticsearch-on-spark-index-mapping/27336 "2015-08-13T14:54:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eliasah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eliasah/32/34741_2.png) [@eliasah](https://discuss.elastic.co/u/eliasah)\
**Post date:** [August 13, 2015, 2:54pm UTC](https://discuss.elastic.co/t/elasticsearch-on-spark-index-mapping/27336/1 "2015-08-13T14:54:45Z")

</div>

Hello everyone,

I'm trying to write a Spark job reading a CSV file and writing into Elasticsearch in Java:

I'm defining my a class object with the following instance variables :

- productId
- title

I have succeeded writing my data into Elasticsearch but I wish to specify that title shouldn't be analyzed.

How can I do that within the Spark job?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![costin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/costin/32/44950_2.png) [@costin](https://discuss.elastic.co/u/costin)\
**Post date:** [August 13, 2015, 7:38pm UTC](https://discuss.elastic.co/t/elasticsearch-on-spark-index-mapping/27336/2 "2015-08-13T19:38:36Z")

</div>

You need to define the mapping before hand in [Elasticsearch](https://www.elastic.co/guide/en/elasticsearch/hadoop/current/mapping.html#_automatic_mapping). There are various reasons why this is like this:

1. it's a one time thing while a job can run multiple times.
2. there is no clear life-cycle hook that the connector can use across all integrations to add the mapping. Also things like versioning, merging conflicts, etc... are not easy to resolve and outside the scope of the connector.

---

<div class="post-metadata">

**Author:** ![eliasah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eliasah/32/34741_2.png) [@eliasah](https://discuss.elastic.co/u/eliasah)\
**Post date:** [August 14, 2015, 6:18am UTC](https://discuss.elastic.co/t/elasticsearch-on-spark-index-mapping/27336/3 "2015-08-14T06:18:18Z")

</div>

That's what I suspect. Thanks for your answer!

Cheers.

---

<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 6, 2017, 1:27pm UTC](https://discuss.elastic.co/t/elasticsearch-on-spark-index-mapping/27336/4 "2017-07-06T13:27:41Z")

</div>


