Dynamically update mapping values

Hi Team,

Below is my index mapping & i need to map 'has_impact' property from 'key_mapping' to the property in 'template_mapping' during run_time.

How do i achieve that? Appreciate your help.

{
  "index-name": {
    "mappings": {
      "key_mapping": {
        "dynamic_templates": [
          {
            "strings": {
              "match_mapping_type": "string",
              "mapping": {
                "index": true,
                "type": "keyword"
              }
            }
          }
        ],
        "properties": {
          "@timestamp": {
            "type": "date"
          },
          "@version": {
            "type": "keyword"
          },
          "has_impact": {
            "type": "long"
          },
          "values": {
            "properties": {
              "alertKey": {
                "type": "keyword"
              }
            }
          }
        }
      },
      "template_mapping": {
        "dynamic_templates": [
          {
            "strings": {
              "match_mapping_type": "string",
              "mapping": {
                "index": true,
                "type": "keyword"
              }
            }
          }
        ],
        "properties": {
          "@timestamp": {
            "type": "date"
          },
          "@version": {
            "type": "keyword"
          },
          "has_impact": {
            "type": "long"
          },
          "values": {
            "properties": {
              "alertKey": {
                "type": "keyword"
              }
            }
          }
        }
      },
      "_default_": {
        "dynamic_templates": [
          {
            "strings": {
              "match_mapping_type": "string",
              "mapping": {
                "index": true,
                "type": "keyword"
              }
            }
          }
        ],
        "properties": {
          "timestamp": {
            "type": "date",
            "format": "epoch_millis||date_time"
          },
          "values": {
            "properties": {
              "code": {
                "type": "integer"
              }
            }
          }
        }
      }
    }
  }
}

You should really change your mappings, multiple types are not supported in Elasticsearch 6.0.

Have a single type and then just move the key_mapping and template_mapping to a field of their own.

Ok. But the intention here, source of data for key_mapping & template_mapping are different, that is the reason i was checking here, is it possible to sync or update the attribute values between mappings.

Can you please give more details in what you explained in ur response?