# ElasticSearch - Reindex to add doc\_value

**URL:** <https://discuss.elastic.co/t/elasticsearch-reindex-to-add-doc-value/2648>\
**Category:** Elasticsearch\
**Created:** [June 14, 2015, 3:36pm UTC](https://discuss.elastic.co/t/elasticsearch-reindex-to-add-doc-value/2648 "2015-06-14T15:36:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![navatm](https://avatars.discourse-cdn.com/v4/letter/n/8e7dd6/32.png) [@navatm](https://discuss.elastic.co/u/navatm)\
**Post date:** [June 14, 2015, 3:36pm UTC](https://discuss.elastic.co/t/elasticsearch-reindex-to-add-doc-value/2648/1 "2015-06-14T15:36:58Z")

</div>

# What am I trying to do?

Add doc\_type to an existing index.

# What have I tried?

## Created index and document

```
POST /my_index-1/my_type/1
{
    "my_prop": "my_value"
}

```

## Added a template

```
PUT /_template/my_template
{
    "id": "my_template",
    "template": "my_index-*",
    "mappings": {
        "_default_": {
            "dynamic_templates": [
                {
                    "my_prop_template": {
                        "mapping": {
                            "index": "not_analyzed",
                            "doc_values": true,
                            "fielddata": {
                                "format": "doc_values"
                            },
                            "type": "string"
                        },
                        "match": "my_prop",
                        "match_mapping_type": "string"
                    }
                }
            ]
        }
    }
}

```

## Reindexed

```
./stream2es es --source http://localhost:9200/my_index-1 --target http://localhost:9200/my_index-2

```

# What went wrong?

In the new index `my_index-2` the property did not receive `"doc_values": true`:

```
...
"properties": {
    "my_prop": {
        "type": "string"
    }
}
...

```

- Just for the sanity, I have also tried adding the same document to my\_index-3, and it got `"doc_values": true`.

# My question

How can I reindex my old index with `"doc_values": true`?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 14, 2015, 4:06pm UTC](https://discuss.elastic.co/t/elasticsearch-reindex-to-add-doc-value/2648/2 "2015-06-14T16:06:14Z")

</div>

The first guess is that this index was already existing ?

---

<div class="post-metadata">

**Author:** ![navatm](https://avatars.discourse-cdn.com/v4/letter/n/8e7dd6/32.png) [@navatm](https://discuss.elastic.co/u/navatm)\
**Post date:** [June 15, 2015, 5:45am UTC](https://discuss.elastic.co/t/elasticsearch-reindex-to-add-doc-value/2648/4 "2015-06-15T05:45:46Z")

</div>

It's not that. The index did not exist before the execution.  
Go ahead and run the commands above.

---

<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 6, 2017, 12:07am UTC](https://discuss.elastic.co/t/elasticsearch-reindex-to-add-doc-value/2648/5 "2017-07-06T00:07:33Z")

</div>


