# Suspected bug: cannot disable a field using dynamic templates

**URL:** <https://discuss.elastic.co/t/suspected-bug-cannot-disable-a-field-using-dynamic-templates/244170>\
**Category:** Elasticsearch\
**Created:** [August 7, 2020, 12:05pm UTC](https://discuss.elastic.co/t/suspected-bug-cannot-disable-a-field-using-dynamic-templates/244170 "2020-08-07T12:05:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![drs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drs/32/8001_2.png) [@drs](https://discuss.elastic.co/u/drs)\
**Post date:** [August 7, 2020, 12:05pm UTC](https://discuss.elastic.co/t/suspected-bug-cannot-disable-a-field-using-dynamic-templates/244170/1 "2020-08-07T12:05:29Z")

</div>

I am trying to use a dynamic template to disable analysis on a field by setting `enabled: false` in its mapping.

This is the mapping I'm using:

```auto
{
  "mappings": {
    "dynamic": true,
    "dynamic_templates": [
      {
        "disable_field": {
          "match": "disabled-field",
          "mapping": {
            "enabled": false
          }
        }
      }
    ]
  }
}

```

When I index this document:

```auto
{
    "disabled-field": "a string"
}

```

The mapping is created with `disabled-field` as type `text`:

```auto
{
  "disabled-field-index" : {
    "mappings" : {
      "dynamic" : "true",
      "dynamic_templates" : [
        {
          "disable_field" : {
            "match" : "disabled-field",
            "mapping" : {
              "enabled" : false
            }
          }
        }
      ],
      "properties" : {
        "disabled-field" : {
          "type" : "text"
        }
      }
    }
  }
}

```

Shouldn't the `disabled-field` have `enabled: false` after indexing the document?

---

<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:** [September 4, 2020, 12:05pm UTC](https://discuss.elastic.co/t/suspected-bug-cannot-disable-a-field-using-dynamic-templates/244170/2 "2020-09-04T12:05:30Z")

</div>

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