arterhuo / blog

1 stars 1 forks source link

ES 添加默认模板 #5

Open huoarter opened 5 years ago

huoarter commented 5 years ago

es6.x之后,一个index不支持多个type

PUT _template/default

{
  "order": 0,
  "index_patterns": [
    "*"
  ],
  "settings": {
    "index": {
      "refresh_interval": "60s",
      "number_of_shards": "5",
      "translog": {
        "flush_threshold_size": "1gb",
        "sync_interval": "60s",
        "durability": "async"
      },
      "number_of_replicas": "1"
    }
  },
  "mappings": {
    "_default_": {
      "properties": {
        "timestamp": {
          "type": "date",
          "format": "strict_date_optional_time||epoch_millis"
        }
      }
    }
  },
  "aliases": {}
}

PUT my_index { "mappings": { "default": { "dynamic_templates": [ { "integers": { "match_mapping_type": "long", "mapping": { "type": "integer" } } }, { "strings": { "match_mapping_type": "string", "mapping": { "type": "text", "fields": { "raw": { "type": "keyword", "ignore_above": 256 } } } } } ] } } } https://www.elastic.co/guide/en/elasticsearch/reference/6.3/dynamic-templates.html { "order": 0, "index_patterns": [ "logstash*" ], "settings": { "index": { "refresh_interval": "60s", "number_of_shards": "60", "translog": { "flush_threshold_size": "1gb", "sync_interval": "120s", "durability": "async" }, "number_of_replicas": "0" } }, "mappings": { "default": { "dynamic_templates": [ { "offset_field": { "match_mapping_type": "long", "mapping": { "type": "long" }, "path_match": "offset" } } ] } }, "aliases": {} }

PUT _template/logstash { "template" : "logstash*", "settings" : { "index" : { "translog": { "flush_threshold_size": "1gb", "sync_interval": "60s", "durability": "async" }, "number_of_shards" : "20", "number_of_replicas": "1", "refresh_interval": "60s" } } }