如何创建关于动态索引类型的弹性搜索模板

How to create elastic search template with respect to dynamic index type

我正在尝试创建关于索引类型的弹性搜索动态模板(按日期,索引将按日期分配创建) 我的示例索引 URL 将是:

http://localhost:9200/my_index/day-01-01-2016
http://localhost:9200/my_index/day-02-01-2016
....

示例模板如下:

PUT my_index
{
  "mappings": {
    "day-*": {          //here, we can't use wild card for index types
      "dynamic_templates": [
       {
          "strings": {
            "match_mapping_type": "string",
            "mapping": {
              "type": "string",
              "fields": {
                "raw": {
                  "type":  "string",
                  "index": "not_analyzed",
                  "ignore_above": 256
                }
              }
            }
          }
        }
      ]
    }
  }
}

创建索引类型模板的方法是什么:"day-*"

正在运行: 我的默认索引如下:

   curl -XPUT localhost:9200/test_index -d '
{
  "mappings": {
    "_default_": {  
      "dynamic_templates": [
        { "my_dtemplate": { 
            "match_mapping_type": "string",
            "mapping": {
              "type": "string",
              "index": "not_analyzed",
              "doc_values": true
            }
        }}
      ]
    }
  }
}'