ElasticSearch - Reindex to add doc_value

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?

The first guess is that this index was already existing ?

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