Elasticsearch实战(二):使用索引模板template

对于日志索引,很多场景都是按日期每天建一个索引,索引对于索引模版的建立非常重要。模版适用于所有提前约定好mapping并且需要动态创建索引的场景。

创建模版示例:

PUT _template/server-log         ##指定模版名

{

  "template" : "server*",            ##匹配所用索引名biz*

  "settings": {

    "index.number_of_replicas": "1",

    "index.number_of_shards": "5",

    "index.translog.flush_threshold_size": "512mb",

    "index.translog.sync_interval": "60s",

    "index.codec": "best_compression"

      },

  "mappings": {

    "doc": {

      "dynamic": "strict",

      "_all": {

        "enabled": false

      },

        "properties": {

        "@timestamp": {

          "type": "date"

        },

       "logdate": {

            "type": "date",

            "format": "yyyyMMdd||yyyy-MM-dd||yyyy/MM/dd||yyyyMMddHHmmss||yyyy-MM-dd HH:mm:ss||yyyy/MM/dd HH:mm:ss||yyyy-MM-dd'T'HH:mm:ss'Z'||yyyy/MM/dd'T'HH:mm:ss'Z'||yyyy/MM/dd HH:mm:ss'Z'||yyyy-MM-dd HH:mm:ss'Z'"

        },

        "message": {

          "norms": false,

          "type": "keyword"

        }

      }

    }

  }

}

更多:elasticsearch专栏

——————————————————————————————————

作者:桃花惜春风

转载请标明出处,原文地址:  

https://blog.csdn.net/xiaoyu_BD/article/details/81738055

如果感觉本文对您有帮助,请留下您的赞,您的支持是我坚持写作最大的动力,谢谢!

猜你喜欢

转载自blog.csdn.net/xiaoyu_BD/article/details/81738055