# Field Mapping using Wildcards - Newbie Question

**URL:** <https://discuss.elastic.co/t/field-mapping-using-wildcards-newbie-question/76300>\
**Category:** Elasticsearch\
**Created:** [February 23, 2017, 7:32pm UTC](https://discuss.elastic.co/t/field-mapping-using-wildcards-newbie-question/76300 "2017-02-23T19:32:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukes](https://avatars.discourse-cdn.com/v4/letter/l/4da419/32.png) [@lukes](https://discuss.elastic.co/u/lukes)\
**Post date:** [February 23, 2017, 7:32pm UTC](https://discuss.elastic.co/t/field-mapping-using-wildcards-newbie-question/76300/1 "2017-02-23T19:32:37Z")

</div>

Hi Experts,

Is it possible to have wildcard type fields mapping ? What i mean is, like in SOLR we can define dynamicFields mapping saying map `*_txt_en to text_en` (convention i am trying to use is "fieldName\_type\_language" and then we define `text_en` as text field with english analyzer and so on. Or may be do direct mapping, I tried

```
{
  "mappings": {
    "type1": {
      "properties": {
        "*_i_en": {
          "type": "integer"
        }
      }
    }
  }
}

```

and tried indexing below field  
{  
"age\_i\_en":25  
}

I checked metadata and it was indexed as long, but not as integer. What i am trying to achieve is define wildcard/regular expression type mappings, so that i can define customize pipelines and so on. And during runtime fields names will get resolved automatically and this way i don't have to define/tie fields names. Also during query time is it possible to specify `"age_i_*"` as query field rather than complete name, so that if i have fields with multiple languages then i don't have to iterate over each of them ?

Any help is appreciated.

Regards,  
Lukes

---

<div class="post-metadata">

**Author:** ![avr](https://avatars.discourse-cdn.com/v4/letter/a/c77e96/32.png) [@avr](https://discuss.elastic.co/u/avr)\
**Post date:** [February 23, 2017, 8:50pm UTC](https://discuss.elastic.co/t/field-mapping-using-wildcards-newbie-question/76300/2 "2017-02-23T20:50:41Z")

</div>

> [@lukes](#):
>
> Is it possible to have wildcard type fields mapping ?

@lukes Yes, wildcard type fields mapping is possible through **dynamic mapping templates**. Look at following mapping:

```
PUT my_index
{
  "mappings": {
    "my_type": {
      "dynamic_templates": [
        {
          "_i_en_as_integers": {
            "match_mapping_type": "*",
            "match": "*_i_en",
            "mapping": {
              "type": "integer"
            }
          }
        }
      ]
    }
  }
}

```

You can read more about dynamic mapping templates [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html#match-unmatch).

> [@lukes](#):
>
> Also during query time is it possible to specify "age\_i\_\*" as query field rather than complete name, so that if i have fields with multiple languages then i don't have to iterate over each of them ?

Yes, this is possible. You can simply search records like this:

```
GET my_index/_search
{
    "query": {
        "query_string" : {
            "default_field" : "age_i_*",
            "query" : "25 30"
        }
    }
}

```

**OR**

```
GET my_index/_search
{
    "query": {
        "query_string" : {
            "query" : "age_i_\\*:25 OR age_i_\\*:30"
        }
    }
}

```

Hope this helps 🙂

---

<div class="post-metadata">

**Author:** ![lukes](https://avatars.discourse-cdn.com/v4/letter/l/4da419/32.png) [@lukes](https://discuss.elastic.co/u/lukes)\
**Post date:** [February 23, 2017, 8:53pm UTC](https://discuss.elastic.co/t/field-mapping-using-wildcards-newbie-question/76300/3 "2017-02-23T20:53:16Z")

</div>

Thanks @avr. I'll give it a shot.

Regards,  
Lukes

---

<div class="post-metadata">

**Author:** ![lukes](https://avatars.discourse-cdn.com/v4/letter/l/4da419/32.png) [@lukes](https://discuss.elastic.co/u/lukes)\
**Post date:** [February 24, 2017, 12:56am UTC](https://discuss.elastic.co/t/field-mapping-using-wildcards-newbie-question/76300/4 "2017-02-24T00:56:13Z")

</div>

That's exactly what i was looking for. Thanks a lot.

Regards,  
Lukes

---

<div class="post-metadata">

**Author:** ![avr](https://avatars.discourse-cdn.com/v4/letter/a/c77e96/32.png) [@avr](https://discuss.elastic.co/u/avr)\
**Post date:** [February 24, 2017, 7:32am UTC](https://discuss.elastic.co/t/field-mapping-using-wildcards-newbie-question/76300/5 "2017-02-24T07:32:49Z")

</div>

@lukes Glad you found it. You can mark the question answered if you feel no further discussion is needed! 🙂

---

<div class="post-metadata">

**Author:** ![lukes](https://avatars.discourse-cdn.com/v4/letter/l/4da419/32.png) [@lukes](https://discuss.elastic.co/u/lukes)\
**Post date:** [February 24, 2017, 5:57pm UTC](https://discuss.elastic.co/t/field-mapping-using-wildcards-newbie-question/76300/6 "2017-02-24T17:57:43Z")

</div>

sure....

Regards,  
Lukes

---

<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:** [March 24, 2017, 5:58pm UTC](https://discuss.elastic.co/t/field-mapping-using-wildcards-newbie-question/76300/7 "2017-03-24T17:58:31Z")

</div>

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