# How to set the analyzer for a field when i usespark-elasticsearch saveToEsWithMeta save to es

**URL:** <https://discuss.elastic.co/t/how-to-set-the-analyzer-for-a-field-when-i-usespark-elasticsearch-savetoeswithmeta-save-to-es/84405>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [May 3, 2017, 11:41am UTC](https://discuss.elastic.co/t/how-to-set-the-analyzer-for-a-field-when-i-usespark-elasticsearch-savetoeswithmeta-save-to-es/84405 "2017-05-03T11:41:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonychan](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@tonychan](https://discuss.elastic.co/u/tonychan)\
**Post date:** [May 3, 2017, 11:41am UTC](https://discuss.elastic.co/t/how-to-set-the-analyzer-for-a-field-when-i-usespark-elasticsearch-savetoeswithmeta-save-to-es/84405/1 "2017-05-03T11:41:51Z")

</div>

my question is how to set the analyzer for a field which's name is changed ,  
my code like as below:

val test ="性别"  
val lbs: Map[String, String] = Map("create\_time" -\> "1491990010000",  
"name" -\> "年龄",  
"values" -\> "70后,80后,90后",  
"label" -\> "{values}",  
"measure" -\>"0.0",  
"tags" -\>"用户画像,灰度发布",  
test-\>"性别,男")  
sc.makeRDD(Seq((1, lbs))).saveToEsWithMeta("label\_sys\_label/label")

my version is 2.4.0  
3q for help!!

---

<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:** [May 6, 2017, 6:59pm UTC](https://discuss.elastic.co/t/how-to-set-the-analyzer-for-a-field-when-i-usespark-elasticsearch-savetoeswithmeta-save-to-es/84405/2 "2017-05-06T18:59:12Z")

</div>

Repeating the response from github on this question:

If you are adding new fields to an index or creating new indices in Elasticsearch from ES-Hadoop you may need to set some sort of index template so that when the new index is created it has the correct mappings and analyzers that you would expect.

---

<div class="post-metadata">

**Author:** ![tonychan](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@tonychan](https://discuss.elastic.co/u/tonychan)\
**Post date:** [May 7, 2017, 5:45am UTC](https://discuss.elastic.co/t/how-to-set-the-analyzer-for-a-field-when-i-usespark-elasticsearch-savetoeswithmeta-save-to-es/84405/3 "2017-05-07T05:45:14Z")

</div>

i dont konw the field in advance，so i cant set at the template ，any way to set at the code

发自网易邮箱大师  
在2017年05月07日 03:09，James Baiera 写道:  
|  
| | james.baieraJames Baiera  
May 6 |  
|  
|

Repeating the response from github on this question:

If you are adding new fields to an index or creating new indices in Elasticsearch from ES-Hadoop you may need to set some sort of index template so that when the new index is created it has the correct mappings and analyzers that you would expect.

|

Visit Topic or reply to this email to respond.

To unsubscribe from these emails, click here.

---

<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:** [May 8, 2017, 1:35am UTC](https://discuss.elastic.co/t/how-to-set-the-analyzer-for-a-field-when-i-usespark-elasticsearch-savetoeswithmeta-save-to-es/84405/4 "2017-05-08T01:35:21Z")

</div>

Unfortunately there is no way to set the mapping from the ES-Hadoop side of things at this time.

---

<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:** [June 5, 2017, 1:49am UTC](https://discuss.elastic.co/t/how-to-set-the-analyzer-for-a-field-when-i-usespark-elasticsearch-savetoeswithmeta-save-to-es/84405/5 "2017-06-05T01:49:28Z")

</div>

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