# Create a mapping that makes all fields type as keyword type

**URL:** <https://discuss.elastic.co/t/create-a-mapping-that-makes-all-fields-type-as-keyword-type/270481>\
**Category:** Elasticsearch\
**Created:** [April 18, 2021, 5:34am UTC](https://discuss.elastic.co/t/create-a-mapping-that-makes-all-fields-type-as-keyword-type/270481 "2021-04-18T05:34:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wangqinghuan](https://avatars.discourse-cdn.com/v4/letter/w/d26b3c/32.png) [@wangqinghuan](https://discuss.elastic.co/u/wangqinghuan)\
**Post date:** [April 18, 2021, 5:34am UTC](https://discuss.elastic.co/t/create-a-mapping-that-makes-all-fields-type-as-keyword-type/270481/1 "2021-04-18T05:34:29Z")

</div>

Hi  
Is there way to create an index that accept all dynamic fields as keyword type in case of type conflict ? For example:

doc 1,

```
   {
      "id":1,
       "name":"Li"
    } 

```

doc 2,

```
{
  "id":"uedjks",
   "name":"Wu"
} 

```

I can make an explicit mapping to specify id and name field type as keyword type :

```
"properties": {
   "id":{
      "type":"keyword"
   },
    "name":{
      "type":"keyword"
   }
}

```

When fields are dynamic and not determined, maybe hunderd or thousand fields, is there any way to make a mapping to accepted all fields as keyword type, such as use \* accepted any field:

```
"properties": {
   "*":{
      "type":"keyword"
   }
}
```

---

<div class="post-metadata">

**Author:** ![wangqinghuan](https://avatars.discourse-cdn.com/v4/letter/w/d26b3c/32.png) [@wangqinghuan](https://discuss.elastic.co/u/wangqinghuan)\
**Post date:** [April 18, 2021, 7:58am UTC](https://discuss.elastic.co/t/create-a-mapping-that-makes-all-fields-type-as-keyword-type/270481/2 "2021-04-18T07:58:21Z")

</div>

Dynamic Template can solve it ! close.

---

<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:** [May 16, 2021, 7:59am UTC](https://discuss.elastic.co/t/create-a-mapping-that-makes-all-fields-type-as-keyword-type/270481/3 "2021-05-16T07:59:12Z")

</div>

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