# Dynamic template, don't want field to be analyzed, only want keyword subfield

**URL:** <https://discuss.elastic.co/t/dynamic-template-dont-want-field-to-be-analyzed-only-want-keyword-subfield/100810>\
**Category:** Elasticsearch\
**Created:** [September 18, 2017, 3:03am UTC](https://discuss.elastic.co/t/dynamic-template-dont-want-field-to-be-analyzed-only-want-keyword-subfield/100810 "2017-09-18T03:03:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankh](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@ankh](https://discuss.elastic.co/u/ankh)\
**Post date:** [September 18, 2017, 3:03am UTC](https://discuss.elastic.co/t/dynamic-template-dont-want-field-to-be-analyzed-only-want-keyword-subfield/100810/1 "2017-09-18T03:03:17Z")

</div>

We're using a dynamic template to specify mapping for certain fields in our index. Most text fields are not mentioned in the template, and get the default mapping to an analyzed field and a keyword subfield:

```
                          "someField" : {
                            "type" : "text",
                            "fields" : {
                              "keyword" : {
                                "type" : "keyword"
                              }
                            }
                          }

```

which is good.

The index has some fields that we don't want to be analyzed, just made keywords. However, for consistency, we want all keyword fields to be a subfield named "keyword", like the above. So this:

```
    "dynamic_templates" : [

      {
        "someField" : {
          "match" : "someField",
          "mapping" : {
            "type" : "keyword",
            "norms" : false
          }
        }
      },

```

isn't suitable, as it makes "someField" itself a keyword, and we want "someField.keyword" to be the keyword field. But if I use this template:

```
    "dynamic_templates" : [

      {
        "someField" : {
          "match" : "someField",
          "mapping" : {
            "fields": {
              "keyword": {
                "type": "keyword",
                "norms" : false
              }
            }
          }
        }
      },

```

an analyzed "top-level" field is created as well as the keyword subfield:

```
                              "someField" : {
                                "type" : "text",
                                "fields" : {
                                  "keyword" : {
                                    "type" : "keyword"
                                  }
                                }
                              },

```

Is there a way to not have the "someField" field mapped, only "someField.keyword"? I could set index : false for the "someField" level, but users may still try to use it, and wonder why it's not working.

---

<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:** [October 16, 2017, 3:03am UTC](https://discuss.elastic.co/t/dynamic-template-dont-want-field-to-be-analyzed-only-want-keyword-subfield/100810/2 "2017-10-16T03:03:18Z")

</div>

Closed on October 16, 2017, 3:03am UTC

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