
1 PUT _template/template_1
2{
3 "index_patterns": ["te*", "bar*"],
4 "aliases" : {
5 "alias1" : {}}
6 "settings": {
7 "number_of_shards": 1
8 },
9 "mappings": {
10 "_source": {
11 "enabled": false
12 },
13 "properties": {
14 "host_name": {
15 "type": "keyword"
16 },
17 "created_at": {
18 "type": "date",
19 "format": "EEE MMM dd HH:mm:ss Z yyyy"
20 }
21 }
22 }
23}
分片数(number_of_shards)、
副本数(number_of_replicas)、
刷新频率(refresh_interval)
…..
1PUT _template/template_1
2...
1DELETE /_template/template_1
1GET /_template/template_1
放了大招。1PUT sampleindex/_doc/1
2{
3 "Value":123
4}
5
6GET sampleindex/_mapping
7
8
9PUT _template/sample_dynamic_template
10{
11 "index_patterns": [
12 "sample*"
13 ],
14 "mappings": {
15 "dynamic_templates": [
16 {
17 "handle_integers": {
18 "match_mapping_type": "long",
19 "mapping": {
20 "type": "integer"
21 }
22 }
23 },
24 {
25 "handle_date": {
26 "match": "date_*",
27 "unmatch": "*_text",
28 "mapping": {
29 "type": "date"
30 }
31 }
32 }
33 ]
34 }
35}
36
37DELETE sampleindex
38PUT sampleindex/_doc/1
39{
40 "Value":123,
41 "date_curtime":"1574494620000"
42}
43
44GET sampleindex/_mapping

1PUT _template/b-template
2{
3 "order":1,
4 "index_patterns":["logstash-b-tomcat-*","logstash-b1-tomcat-*","logstash-b2-server-*","logstash-b3-tomcat-*"],
5 "settings":{
6 "number_of_shards":"5",
7 "number_of_replicas":"1",
8 "refresh_interval":"30s",
9 "translog.durability":"async"
10 }
11}
12
13PUT logstash-b-tomcat-1
14
15PUT _template/a-template
16{
17 "order":0,
18 "index_patterns":["*"],
19 "settings":{
20 "number_of_shards":"5",
21 "number_of_replicas":"0",
22 "refresh_interval":"30s",
23 "translog.durability":"async"
24 }
25}

更短时间,更快习得更多干货!
原文作者:铭毅天下Elasticsearch;如有侵权,请联系管理员删除。