# Elasticsearch enable doc\_values for all non-analyzed fields in template and re-index

**URL:** <https://discuss.elastic.co/t/elasticsearch-enable-doc-values-for-all-non-analyzed-fields-in-template-and-re-index/34600>\
**Category:** Elasticsearch\
**Created:** [November 14, 2015, 8:52pm UTC](https://discuss.elastic.co/t/elasticsearch-enable-doc-values-for-all-non-analyzed-fields-in-template-and-re-index/34600 "2015-11-14T20:52:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![deepak\_deore](https://avatars.discourse-cdn.com/v4/letter/d/9fc29f/32.png) [@deepak\_deore](https://discuss.elastic.co/u/deepak_deore)\
**Post date:** [November 14, 2015, 8:52pm UTC](https://discuss.elastic.co/t/elasticsearch-enable-doc-values-for-all-non-analyzed-fields-in-template-and-re-index/34600/1 "2015-11-14T20:52:37Z")

</div>

ES version: 1.5.2 (amazon elasticearch service)

How do I enable doc values for all non-analyzed fields in template from API ? So that indices being crated will have doc values enabled. After this how do I re-index old indices from API which will enable doc values for old indices also.

Here is my template:

```
$ curl -s 'http://AWS_ES/_template?pretty=true/'
{
  "logstash" : {
    "order" : 0,
    "template" : "logstash-*",
    "settings" : {
      "index.refresh_interval" : "5s"
    },
    "mappings" : {
      "_default_" : {
        "dynamic_templates" : [ {
          "message_field" : {
            "mapping" : {
              "index" : "analyzed",
              "omit_norms" : true,
              "type" : "string"
            },
            "match_mapping_type" : "string",
            "match" : "message"
          }
        }, {
          "string_fields" : {
            "mapping" : {
              "index" : "analyzed",
              "omit_norms" : true,
              "type" : "string",
              "fields" : {
                "raw" : {
                  "ignore_above" : 256,
                  "index" : "not_analyzed",
                  "type" : "string"
                }
              }
            },
            "match_mapping_type" : "string",
            "match" : "*"
          }
        } ],
        "_all" : {
          "omit_norms" : true,
          "enabled" : true
        },
        "properties" : {
          "geoip" : {
            "dynamic" : true,
            "type" : "object",
            "properties" : {
              "location" : {
                "type" : "geo_point"
              }
            }
          },
          "@version" : {
            "index" : "not_analyzed",
            "type" : "string"
          }
        }
      }
    },
    "aliases" : { }
  }
}
```

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [November 15, 2015, 9:27am UTC](https://discuss.elastic.co/t/elasticsearch-enable-doc-values-for-all-non-analyzed-fields-in-template-and-re-index/34600/2 "2015-11-15T09:27:42Z")

</div>

You already know how to extract the existing index template, so modify the template and update it with a PUT operation. Keep in mind that Logstash with the default settings will manage the logstash-\* index template for you so you might want to disable that if you want to manage them yourself, or you can reconfigure Logstash to use a different index template file than the default. See the options of the [elasticsearch output](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html).

To reindex the documents to a new index you can use Logstash itself, [es-reindex](https://github.com/geronime/es-reindex), or a custom script written in e.g. Python. Keep in mind that indexes can't be renamed, so you have to reindex into an index with new name, e.g. based on the original name but with a suffix. After deleting the original index you can create an index alias that allows you to use the index under the old name.

---

<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:38pm UTC](https://discuss.elastic.co/t/elasticsearch-enable-doc-values-for-all-non-analyzed-fields-in-template-and-re-index/34600/3 "2017-07-05T23:38:25Z")

</div>


