# How to enable store on keyword subfield in elasticsearch in case of dynamic mapping

**URL:** <https://discuss.elastic.co/t/how-to-enable-store-on-keyword-subfield-in-elasticsearch-in-case-of-dynamic-mapping/205982>\
**Category:** Elasticsearch\
**Created:** [October 31, 2019, 6:26am UTC](https://discuss.elastic.co/t/how-to-enable-store-on-keyword-subfield-in-elasticsearch-in-case-of-dynamic-mapping/205982 "2019-10-31T06:26:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![prakhara](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prakhara/32/45904_2.png) [@prakhara](https://discuss.elastic.co/u/prakhara)\
**Post date:** [October 31, 2019, 6:26am UTC](https://discuss.elastic.co/t/how-to-enable-store-on-keyword-subfield-in-elasticsearch-in-case-of-dynamic-mapping/205982/1 "2019-10-31T06:26:38Z")

</div>

how to enable store on keyword subfield in elasticsearch in case of dynamic mapping

---

<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:** [November 4, 2019, 8:41pm UTC](https://discuss.elastic.co/t/how-to-enable-store-on-keyword-subfield-in-elasticsearch-in-case-of-dynamic-mapping/205982/2 "2019-11-04T20:41:45Z")

</div>

Yes, you could use a [dynamic template](https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html) for that. Dynamic templates allow you to change how fields get mapped dynamically. In your case, you could use that to enable `store` on all dynamically mapped `keyword` multifields:

```auto
PUT my_index
{
  "mappings": {
    "dynamic_templates": [
      {
        "strings": {
          "match_mapping_type": "string",
          "mapping": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256,
                "store": true
              }
            }
          }
        }
      }
    ]
  }
}

```

---

<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:** [December 2, 2019, 8:41pm UTC](https://discuss.elastic.co/t/how-to-enable-store-on-keyword-subfield-in-elasticsearch-in-case-of-dynamic-mapping/205982/3 "2019-12-02T20:41:50Z")

</div>

Closed on December 2, 2019, 8:41pm UTC

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