# Using Dynamic Mappings for language related Fields

**URL:** <https://discuss.elastic.co/t/using-dynamic-mappings-for-language-related-fields/23522>\
**Category:** Elasticsearch\
**Created:** [May 3, 2015, 3:26pm UTC](https://discuss.elastic.co/t/using-dynamic-mappings-for-language-related-fields/23522 "2015-05-03T15:26:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![guilhermejkr](https://avatars.discourse-cdn.com/v4/letter/g/7ba0ec/32.png) [@guilhermejkr](https://discuss.elastic.co/u/guilhermejkr)\
**Post date:** [May 3, 2015, 3:26pm UTC](https://discuss.elastic.co/t/using-dynamic-mappings-for-language-related-fields/23522/1 "2015-05-03T15:26:48Z")

</div>

Hello,  
I have a system with multiple fields, some in English and some in Japanese,  
I have installed a plugin and after a bit of help added the mapping and it  
worked, however, since the mapping was for a specific field It would not  
work when I queried for "\_all" it did not work, I am trying to add a  
dynamic mapping for it, as below, however, It is failing:

```
    XContentBuilder xbMapping =
            jsonBuilder()
                    .startObject()
                    .startObject("mappings")
                    .startObject(indexType)
                    .startObject("dynamic_templates")
                    .startObject("jp")
                    .field("match", "*")
                    .field("match_mapping_type", "string")
                    .startObject("mapping")
                    .field("type", "string")
                    .field("analyzer", JAPANESE_LANGUzzAGE_ANALYSIS)
                    .endObject()
                    .endObject()
                    .endObject()
                    .endObject()
                    .endObject();

             elasticSearchClient.admin().indices()
            .preparePutMapping(indexName)
            .setType(indexType)
            .setSource(xbMapping)
            .execute().get();

```

Any Ideas on what I am doing wrong? And if I add this mapping to "\*" will I  
still be able to perform queries without passing the analyser? or should I  
use different types for each document I add depending on the language?

Thank you

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/5efb000d-1fad-4bef-abca-ae16c503c2de%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5efb000d-1fad-4bef-abca-ae16c503c2de%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![johtani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johtani/32/44956_2.png) [@johtani](https://discuss.elastic.co/u/johtani)\
**Post date:** [May 15, 2015, 3:03am UTC](https://discuss.elastic.co/t/using-dynamic-mappings-for-language-related-fields/23522/2 "2015-05-15T03:03:29Z")

</div>

Hi

`_all` field is metadata field.  
It uses the default analyzer to analyze its values.

This section will help you.

> **[Metadata: \_all Field - The Root Object | Elasticsearch: The Definitive Guide...](https://www.elastic.co/guide/en/elasticsearch/guide/current/root-object.html#all-field)**

And the following article, Dealing with Human Language, will help you to  
deal with multi languages.

> **[Getting Started with Languages | Elasticsearch: The Definitive Guide \[2.x\] |...](https://www.elastic.co/guide/en/elasticsearch/guide/current/language-intro.html)**

2015-05-04 0:26 GMT+09:00 [guilhermejkr@gmail.com](mailto:guilhermejkr@gmail.com):

> Hello,  
> I have a system with multiple fields, some in English and some in  
> Japanese, I have installed a plugin and after a bit of help added the  
> mapping and it worked, however, since the mapping was for a specific field  
> It would not work when I queried for "\_all" it did not work, I am trying to  
> add a dynamic mapping for it, as below, however, It is failing:
> 
> ```
> XContentBuilder xbMapping =
> jsonBuilder()
> .startObject()
> .startObject("mappings")
> .startObject(indexType)
> .startObject("dynamic_templates")
> .startObject("jp")
> .field("match", "*")
> .field("match_mapping_type", "string")
> .startObject("mapping")
> .field("type", "string")
> .field("analyzer", JAPANESE_LANGUzzAGE_ANALYSIS)
> .endObject()
> .endObject()
> .endObject()
> .endObject()
> .endObject();
> 
> elasticSearchClient.admin().indices()
> .preparePutMapping(indexName)
> .setType(indexType)
> .setSource(xbMapping)
> .execute().get();
> 
> ```
> 
> Any Ideas on what I am doing wrong? And if I add this mapping to "\*" will  
> I still be able to perform queries without passing the analyser? or should  
> I use different types for each document I add depending on the language?
> 
> Thank you
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/5efb000d-1fad-4bef-abca-ae16c503c2de%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5efb000d-1fad-4bef-abca-ae16c503c2de%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/5efb000d-1fad-4bef-abca-ae16c503c2de%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/5efb000d-1fad-4bef-abca-ae16c503c2de%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

## --

Jun Ohtani  
blog : [http://blog.johtani.info](http://blog.johtani.info)

## -- Please update your bookmarks! We have moved to [https://discuss.elastic.co/](https://discuss.elastic.co/)

You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAPW8A5yR\_SQo6dZpXm7FiGFtTwDbyAFC9dDiBYh\_C-N\_kKRREw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPW8A5yR_SQo6dZpXm7FiGFtTwDbyAFC9dDiBYh_C-N_kKRREw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:13am UTC](https://discuss.elastic.co/t/using-dynamic-mappings-for-language-related-fields/23522/3 "2017-07-06T00:13:56Z")

</div>


