# How to modify ES to create field default values?

**URL:** <https://discuss.elastic.co/t/how-to-modify-es-to-create-field-default-values/110081>\
**Category:** Elasticsearch\
**Created:** [December 4, 2017, 2:55am UTC](https://discuss.elastic.co/t/how-to-modify-es-to-create-field-default-values/110081 "2017-12-04T02:55:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark6688](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@mark6688](https://discuss.elastic.co/u/mark6688)\
**Post date:** [December 4, 2017, 2:55am UTC](https://discuss.elastic.co/t/how-to-modify-es-to-create-field-default-values/110081/1 "2017-12-04T02:55:29Z")

</div>

Hi Everyone.

I want to know how to modify the default value of the ES creation field?  
For example:  
I'm going to insert a piece of data.  
Add the dizhi field, the default type is text, the participle.

I want to add the dizhi field, the default type is keyword, no participle  
I hope to get some solutions. Thank you very much.  
 ![1](https://us1.discourse-cdn.com/elastic/original/3X/6/3/63c999ac3e4d8fbc82dcf28ae1c301caf9a8b100.png)

---

<div class="post-metadata">

**Author:** ![zqc0512](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zqc0512/32/32141_2.png) [@zqc0512](https://discuss.elastic.co/u/zqc0512)\
**Post date:** [December 4, 2017, 3:08am UTC](https://discuss.elastic.co/t/how-to-modify-es-to-create-field-default-values/110081/2 "2017-12-04T03:08:10Z")

</div>

use mapping to update is.

---

<div class="post-metadata">

**Author:** ![mark6688](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@mark6688](https://discuss.elastic.co/u/mark6688)\
**Post date:** [December 4, 2017, 3:22am UTC](https://discuss.elastic.co/t/how-to-modify-es-to-create-field-default-values/110081/3 "2017-12-04T03:22:38Z")

</div>

Can the default part of the keyword type be inserted by default by configuration modification? How do you do it?

---

<div class="post-metadata">

**Author:** ![infomaniac](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/infomaniac/32/24996_2.png) [@infomaniac](https://discuss.elastic.co/u/infomaniac)\
**Post date:** [December 4, 2017, 3:28pm UTC](https://discuss.elastic.co/t/how-to-modify-es-to-create-field-default-values/110081/4 "2017-12-04T15:28:49Z")

</div>

Change your mapping.

```auto
....
"dizhi" : {
  "type" : "keyword"
},
....

```

Note that this only can be set when creating a new index. You cannot change an existing index.  
If you need to change existing data, you will have to reindex.

---

<div class="post-metadata">

**Author:** ![mark6688](https://avatars.discourse-cdn.com/v4/letter/m/f17d59/32.png) [@mark6688](https://discuss.elastic.co/u/mark6688)\
**Post date:** [December 5, 2017, 6:54am UTC](https://discuss.elastic.co/t/how-to-modify-es-to-create-field-default-values/110081/5 "2017-12-05T06:54:55Z")

</div>

OK thank you

---

<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:** [January 2, 2018, 6:55am UTC](https://discuss.elastic.co/t/how-to-modify-es-to-create-field-default-values/110081/6 "2018-01-02T06:55:42Z")

</div>

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