1、 引言2、Elasticsearch模板是什么鬼?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} index_patterns代表匹配的索引。 settings 指索引层面的设置。 可以设置索引层面的配置,包括:
….. 3、Elasticsearch模板的基础操作3.1 增2... 3.2 删3.3 改3.4 查4、Elasticsearch模板进阶实战放了大招 。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
5、常见问题问题1:template和Mapping到底什么区别?
问题2:模板里可以指定Mapping,那我们还需要Mapping做什么?
问题3:如果我想更新Mapping,更新模板可以吗?
问题4:模板order起到什么作用?
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} 6、小结相比之下Mapping和别名优势如下:
更短时间,更快习得更多干货! |
|