# Mapping fields cannot be replaced during template composition

**URL:** <https://discuss.elastic.co/t/mapping-fields-cannot-be-replaced-during-template-composition/248217>\
**Category:** Elasticsearch\
**Created:** [September 10, 2020, 6:18pm UTC](https://discuss.elastic.co/t/mapping-fields-cannot-be-replaced-during-template-composition/248217 "2020-09-10T18:18:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lolo\_Bee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lolo_bee/32/75378_2.png) [@Lolo\_Bee](https://discuss.elastic.co/u/Lolo_Bee)\
**Post date:** [September 10, 2020, 6:18pm UTC](https://discuss.elastic.co/t/mapping-fields-cannot-be-replaced-during-template-composition/248217/1 "2020-09-10T18:18:47Z")

</div>

Hi, I'm trying to setup a template index composed of some component templates. One of the component templates creates new fields mapping on an existing object, and this raises the following error _"mapping fields [tcp] cannot be replaced during template composition"_

Here are the steps to reproduce:

```auto
    PUT _component_template/tcp_service
    {"template": {
                "mappings": {
                    "properties": {
                        "tcp": {
                            "properties": {
                                "tcpService": {
                                    "type": "keyword"
                                },
                                "udpService": {
                                    "type": "keyword"
                                }
                            }
                        }
                    }
                }
            }
        }

```

Which responds

```auto
    {
    "acknowledged" : true
    }

```

And then create the index\_template

```auto
    PUT _index_template/data
    {
       "index_patterns": ["data_*"],
       "composed_of": ["tcp_service"],
       "template": {
              "aliases": {
                     "data": {}
              },
       "settings": {
           "index": {
               "number_of_shards": "2",
               "number_of_replicas": "1"
           }
       },
       "mappings": {
           "properties": {
              "tcp": {
                   "properties": {
                       "dstPort": {
                           "type": "keyword"
                       }
                   }
                }
             }
          }
       }
    }

```

And the answer

```auto
        {
      "error" : {
        "root_cause" : [
          {
            "type" : "illegal_argument_exception",
            "reason" : "composable template [data] template after composition with component templates [tcp_service] is invalid"
          }
        ],
        "type" : "illegal_argument_exception",
        "reason" : "composable template [data] template after composition with component templates [tcp_service] is invalid",
        "caused_by" : {
          "type" : "illegal_argument_exception",
          "reason" : "invalid composite mappings for [data]",
          "caused_by" : {
            "type" : "illegal_argument_exception",
            "reason" : "mapping fields [tcp] cannot be replaced during template composition"
          }
        }
      },
      "status" : 400
    }

```

Am I trying to do anything impossible?  
Is the only way to accomplish this to include component\_template fields in index\_template?  
Can't Objects be updated with component\_templates?

Kind regards, Manuel

---

<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:** [October 8, 2020, 6:18pm UTC](https://discuss.elastic.co/t/mapping-fields-cannot-be-replaced-during-template-composition/248217/2 "2020-10-08T18:18:54Z")

</div>

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