es的索引库模板

在实际的生产中,如果要插入大批量数据的时候需要使用多个索引库,如果我们还是手工指定每个索引的配置信息settings和mappings,是非常耗时的;

针对这种情况,es有index template可以解决上面的问题;

索引可使用预定义的模板进行创建,这个模板称作Index templates。模板设置包括settings和mappings通过模式匹配的方式使得多个索引重用一个模板。

curl -XPUT hadoop01:9200/_template/my_template -d '
{
    "template" : "my_index*",
    "order" : 0,
    "settings" : {
        "number_of_shards" : 1
    },
    "mappings" : {
        "type1" : {
            "_source" : { "enabled" : false }
        }
    }
}
'


curl -XGET hadoop01:9200/_template/my_template?pretty
原文地址:https://www.cnblogs.com/niutao/p/10909349.html