elasticsearch模板配置

来源:互联网 发布:淘宝客微信群 编辑:程序博客网 时间:2024/06/05 08:53
配置所有string字段都不分词
新建文件dynamic_templates,内容如下:
{
"template": "*",
"mappings": {
"logs": {
"dynamic_templates": [
{
"strings": {
"match_mapping_type": "string",
"mapping": {
"type": "keyword"
}
}
}
]
}
}
}

创建脚本:update_dynamic_templates.sh ,内容如下
#!/bin/bash
auth=elastic:changeme
echo update template mobreq mobperf srvmonitor...
cd /data/services/elastic/templates
curl -XPUT -u $auth http://localhost:9200/_template/dynamic_templates -d @dynamic_templates
curl -u $auth http://localhost:9200/_template/dynamic_templates?pretty
echo "update end.."

update_dynamic_templates.sh和dynamic_templates放在同一目录下,运行update_dynamic_templates.sh就行。
注意,模板对新建的库才有效果

另外,附带一个完整一点的配置作参考
{
"order": 14,
"template": "aomimodeldata-*",
"settings": {
"refresh_interval": "10s",
"index.number_of_shards": 12,
"index.number_of_replicas": 1,
"index.max_result_window": 200000,
"search.slowlog.threshold.query.warn": "10s",
"search.slowlog.threshold.query.info": "5s",
"indexing.slowlog.threshold.index.warn": "10s",
"indexing.slowlog.threshold.index.info": "5s"
},
"mappings": {
"logs": {
"dynamic": true,
"_all" : {
"enabled" : false
},
"properties": {
"app.srvid":{
"type":"keyword"
},
"source":{
"type":"keyword"
},
"app.groupid":{
"type":"keyword"
},
"model.ctx.svrname":{
"type":"keyword"
},
"model.id":{
"type":"keyword"
},
"app.clientname":{
"type":"keyword"
},
"app.ips":{
"type":"keyword"
},
"app.ports":{
"type":"keyword"
},
"@timestamp":{
"type":"date"
}
}
}
}
}






原创粉丝点击