# Analyzer rule based on properties with wildcard

**URL:** <https://discuss.elastic.co/t/analyzer-rule-based-on-properties-with-wildcard/48312>\
**Category:** Elasticsearch\
**Created:** [April 25, 2016, 11:39am UTC](https://discuss.elastic.co/t/analyzer-rule-based-on-properties-with-wildcard/48312 "2016-04-25T11:39:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![boeledi01](https://avatars.discourse-cdn.com/v4/letter/b/94ad74/32.png) [@boeledi01](https://discuss.elastic.co/u/boeledi01)\
**Post date:** [April 25, 2016, 11:39am UTC](https://discuss.elastic.co/t/analyzer-rule-based-on-properties-with-wildcard/48312/1 "2016-04-25T11:39:45Z")

</div>

Hi,

I need to store documents with content in several different languages in a same document.  
In order to store these documents, I was thinking of suffixing these properties with the corresponding language code.

Example:  
json = { "text\_en": "the text in English", "text\_fr": "the text in French", "text\_ru": "the text in Russian", "another\_text\_it": "this one in Italian"}

These document will also be nested objects and the structure will not be fixed.

Therefore I was looking for a solution to create a mapping that would consider "suffixes" to apply language-specific analyzers, such as:

"mappings": {  
...  
"properties": {  
"_\_en": {  
"type": "string",  
"language": "english"  
},  
"_\_fr": {  
"type": "string",  
"language": "french"  
}  
...and so forth.

Could somebody tell me if this is possible?

Many thanks

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [April 27, 2016, 9:20am UTC](https://discuss.elastic.co/t/analyzer-rule-based-on-properties-with-wildcard/48312/2 "2016-04-27T09:20:15Z")

</div>

Take a look at [dynamic templates](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html). Dynamic templates allow you to define mappings based on wildcards matching a field name.

Something like this should do what you are trying to achieve:

```
  "mappings": {
    "my_type": {
      "dynamic_templates": [
        {
          "english_fields": {
            "match": "*_en",
            "mapping": {
              "analyzer": "english"
            }
          }
        },
        {
          "french_fields": {
            "match": "*_fr",
            "mapping": {
              "analyzer": "french"
            }
          }
        }
      ]
    }
  }
```

---

<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 5, 2017, 10:56pm UTC](https://discuss.elastic.co/t/analyzer-rule-based-on-properties-with-wildcard/48312/3 "2017-07-05T22:56:02Z")

</div>

Closed on July 5, 2017, 10:56pm UTC


