Field alias in dynamic template

Hello,

Is it possible to put field alias in dynamic template? if so, can you please share some samples with field alias? I tried to find elastic document but couldn't find.

FYI,
currently I am working on below template but I need to add field alias (e.g. "time-taken" field alias with "time-taken-ms" field).

please advise. thank you!!

PUT _template/cloudfront_logs
{
  "index_patterns": [
    "cloudfront_*"
  ],
  "settings": {
    "number_of_replicas": 1,
    "number_of_shards": 3
  },
  "mappings": {
    "_doc": {
      "dynamic_templates": [
        {
          "time-taken": {
            "mapping": {
              "type": "long"
            },
            "match": "time-taken"
          }
        },
        {
          "content-length": {
            "mapping": {
              "type": "long"
            },
            "match": "content-length"
          }
        },
        {
          "cs-bytes": {
            "mapping": {
              "type": "long"
            },
            "match": "cs-bytes"
          }
        },
        {
          "sc-bytes": {
            "mapping": {
              "type": "long"
            },
            "match": "sc-bytes"
          }
        },
        {
          "strings": {
            "mapping": {
              "type": "keyword"
            },
            "match_mapping_type": "string"
          }
        }
      ]
    }
  }
}

self replying.....

I guess I solved my problem as below (highlighted with bold). :slight_smile:

PUT _template/cloudfront_logs
{
  "index_patterns": [
    "cloudfront_*"
  ],
  "settings": {
    "number_of_replicas": 1,
    "number_of_shards": 3
  },
  "mappings": {
    "_doc": {
      **"properties": {**
**            "c-ip": {**
**              "type": "keyword"**
**            },**
**            "client-ip": {**
**              "type": "alias",**
**              "path": "c-ip"**
**            }**
**          },**
      "dynamic_templates": [
        {
          "time-taken": {
            "mapping": {
              "type": "long"
            },
            "match": "time-taken"
          }
        },
...

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