# Disable field based on its name

**URL:** <https://discuss.elastic.co/t/disable-field-based-on-its-name/41199>\
**Category:** Elasticsearch\
**Created:** [February 8, 2016, 3:54pm UTC](https://discuss.elastic.co/t/disable-field-based-on-its-name/41199 "2016-02-08T15:54:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![carlosrdrz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carlosrdrz/32/7653_2.png) [@carlosrdrz](https://discuss.elastic.co/u/carlosrdrz)\
**Post date:** [February 8, 2016, 3:54pm UTC](https://discuss.elastic.co/t/disable-field-based-on-its-name/41199/1 "2016-02-08T15:54:15Z")

</div>

Hi,

I'm using ElasticSearch 1.5 and using the bulk API to index a bunch of data.

I want to get rid of some fields that are present in the documents that are being indexed.

I'm using a template to create the mappings and right now I'm adding those fields as disabled fields like this:

```auto
"properties: {
  "ns_used_0": { "enabled": false },
  "ns_used_1": { "enabled": false },
  "ns_used_2": { "enabled": false },
  "ns_used_3": { "enabled": false },
  "ns_used_4": { "enabled": false },
  "ns_used_5": { "enabled": false },
  [more...]
}

```

But I don't really want to do that because that list can grow a lot in the future.  
I want to disable every field that starts with "ns\_".

I thought of using dynamic templates like this:

```auto
"dynamic_templates": [
  {
    "ignored": {
      "match": "ns_*",
      "match_mapping_type": "string",
      "mapping": { "enabled": "false" }
    }
  }
]

```

But that is not working for me. I can see in Kibana that the fields are being added.

Am I missing something? Is there any other way to do that?

---

<div class="post-metadata">

**Author:** ![abeyad](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@abeyad](https://discuss.elastic.co/u/abeyad)\
**Post date:** [February 9, 2016, 6:56am UTC](https://discuss.elastic.co/t/disable-field-based-on-its-name/41199/2 "2016-02-09T06:56:46Z")

</div>

Try changing `"mapping": {"enabled": "false"}` to `"mapping": { "index: "no" }`

Does that help?

---

<div class="post-metadata">

**Author:** ![carlosrdrz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carlosrdrz/32/7653_2.png) [@carlosrdrz](https://discuss.elastic.co/u/carlosrdrz)\
**Post date:** [February 9, 2016, 8:59am UTC](https://discuss.elastic.co/t/disable-field-based-on-its-name/41199/3 "2016-02-09T08:59:18Z")

</div>

That works with dynamic\_templates, but unfortunately, it doesn't have _exactly_ the same effect.

I suppose that if we set index to no, the field won't be present in the index and I won't be able to search documents based on that field, but it's present on ES, Kibana knows about it, and I can get their value once I've found a document.

However, when the document is disabled, I can't search it and I can't see it in Kibana nor in ES documents.

Not sure what's the exactly internal difference in terms of performance, though.

Thanks!

---

<div class="post-metadata">

**Author:** ![abeyad](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@abeyad](https://discuss.elastic.co/u/abeyad)\
**Post date:** [February 9, 2016, 5:08pm UTC](https://discuss.elastic.co/t/disable-field-based-on-its-name/41199/4 "2016-02-09T17:08:54Z")

</div>

You could set "stored" to "no" as well and make sure to exclude the fields  
from \_source, see:  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-source-field.html#include-exclude](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-source-field.html#include-exclude)

---

<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:** [July 5, 2017, 11:17pm UTC](https://discuss.elastic.co/t/disable-field-based-on-its-name/41199/5 "2017-07-05T23:17:54Z")

</div>


