'Elasticsearch copy multi fields to one field and do not mapping source field?

There are too many similar fields from data source, I want to copy them to one field, and do not mapping these similar fields. Here is my dynamic template:

[
  {
    "username": {
      "path_match": "facts.wifi*username",
      "mapping": {
        "copy_to": "username",
        "type": "keyword",
        "enabled": false
      }
    }
  },
  {
    "ipaddress": {
      "path_match": "facts.ipaddress*",
      "mapping": {
        "copy_to": "ipaddress",
        "type": "keyword",
        "enabled": false
      }
    }
  },
  {
    "macaddress": {
      "path_match": "facts.macaddress*",
      "mapping": {
        "copy_to": "macaddress",
        "type": "keyword",
        "enabled": false
      }
    }
  },
  {
    "ignore_others": {
      "path_match": "facts.*",
      "mapping": {
        "type": "object",
        "enabled": false
      }
    }
  }
]

BUT When I write data to index, ES says "enabled=false" is invalid and ignore it.

#! Deprecation: dynamic template [username] has invalid content [{"path_match":"facts.wifi*username","mapping":{"copy_to":"username","enabled":false,"type":"keyword"}}], caused by [Unused mapping attributes [{enabled=false}]]
#! Deprecation: dynamic template [ipaddress] has invalid content [{"path_match":"facts.ipaddress*","mapping":{"copy_to":"ipaddress","enabled":false,"type":"keyword"}}], caused by [Unused mapping attributes [{enabled=false}]]
#! Deprecation: dynamic template [macaddress] has invalid content [{"path_match":"facts.macaddress*","mapping":{"copy_to":"macaddress","enabled":false,"type":"keyword"}}], caused by [Unused mapping attributes [{enabled=false}]] 

I try to update mapping config to this:

"index": false,
"doc_values": false

It succeeded to write data into index, I can not filter or aggregate those fields, but still have field mapping.

Can anyone help me to figure it out? Is it possible to do so in elasticsearh, or do I make some mistakes?

my elasticsearch version is 7.7.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source