elasticsearch 配置模板
GET _cat/templates PUT _template/template_base 【错误做法,勿执行】 { "template" : "*", "order" : 0, "settings" : { "number_of_shards" : 5, "number_of_replicas" : 1 }, "mappings" : { "type1" : { "_source" : { "enabled" : false } } } }
curl -XGET "http://192.168.1.11:9200/_cat/templates"
curl -XPUT "http://192.168.1.11:9200/_template/template_base" -H 'Content-Type: application/json' -d' 【错误做法,勿执行】
{ "template" : "*", "order" : 0, "settings" : { "number_of_shards" : 5, "number_of_replicas" : 1 }, "mappings" : { "type1" : { "_source" : { "enabled" : false } } } }'
【正确做法,使用系统默认的mappings】 不然会的导致报错:[Rejecting mapping update to [.monitoring-es-6-2019.06.04] as the final mapping would have more than 1 type: [doc, type1]]
PUT _template/template_base { "template" : "*", "order" : 0, "settings" : { "number_of_shards" : 5, #分片数量 "number_of_replicas" : 1 #副本数量 < 可用节点数 }, "mappings": { "doc": { "properties": { "@timestamp": { "type": "date" }, "data": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "fields": { "properties": { "host_ip": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "project": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "type": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } } } }, "host": { "properties": { "name": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } } } }, "level": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "log": { "properties": { "file": { "properties": { "path": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } } } } } }, "name": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "server": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "source": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "tags": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "time": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } } } } } }
一些事情一直在干,说不定以后就结果了呢
本文来自博客园,作者:chenjianwen,转载请注明原文链接:https://www.cnblogs.com/chenjw-note/articles/10966789.html