2016-07-29 42 views

回答

2

在索引模板中,只需將映射定義爲動態模板即可。 例如:

PUT /_template/template_1 
{ 
    "template": "yourindex*", 
    "mappings": { 
    "my_type": { 
     "dynamic_templates": [ 
     {your dynamic templates ...} 
     ] 
    } 
    } 
} 
1

你可以做這樣的事情:

PUT /_template/my_template 
{ 
    "template": "name-*", 
    "mappings": { 
    "my_type": { 
     "dynamic_templates": [ 
     { 
      "rule1": { 
      "match": "field*", 
      "mapping": { 
       "type": "string", 
       "index": "analyzed" 
      } 
      } 
     }, 
     { 
      "rule2": { 
      "match": "another*", 
      "mapping": { 
       "type": "integer" 
      } 
      } 
     } 
     ], 
     "properties": { 
     "field": { 
      "type": "string" 
     } 
     } 
    } 
    } 
}