1、网上都是Linux下如何在控制台操作。小白还没走到Linux下,还在Windows下搭建es。
新建模板
咱们通常在elasticsearch中 post mapping信息,每重新创建索引便到设置mapping,分片,副本信息。非常繁琐。强烈建议大家通过设置template方式设置索引信息。设置索引名,通过正则匹配的方式匹配到相应的模板。ps:直接修改mapping的优先级>索引template。索引匹配了多个template,当属性等配置出现不一致的,以order的最大值为准,order默认值为0
语句 (_template是新建模板操作,template1自己起的模板名字)
PUT http://localhost:9200/_template/template1
json 内容
{
"template": "bl*",
"settings": {
"number_of_shards": 1
},
"mappings": {
"type1": {
"_source": {
"enabled": false
},
"properties": {
"tags": {
"type": "string",
"analyzer": "ik_smart",
"search_analyzer": "ik_smart"
}
}
}
}
}
说明: (1)模板template_1匹配所有的以bl开头的索引。也可设