您的位置 首页 elasticsearch

es 索引模板

es 索引模板

什么是索引模板:
索引模板是创建索引的一种方式。(就是已经有了索引模板,我们创建索引的时候直接用模板就可以。)
当数据写入指定索引时,如果该索引不存在,则根据索引名称匹配相应索引模板的话,会根据模板的配置而创建索引。
索引模板仅对新创建的索引生效,对已经创建的索引是没有任何作用的。

推荐阅读:
https://www.elastic.co/guide/en/elasticsearch/reference/7.17/index-templates.html

 

索引模板的管理

- 查
查看所有的所有模板

http://10.0.0.113:19200/_template

查看指定的索引模板

 http://10.0.0.113:19200/_template/.monitoring-es

 

- 增

POST  http://10.0.0.113:19200/_template/baimei

 

{
    "aliases": {
        "DBA": {},
        "SRE": {},
        "K8S": {}
    },
    "index_patterns": [
        "baimeidashu-linux86*"
    ],
    "settings": {
        "index": {
            "number_of_shards": 3,
            "number_of_replicas": 0
        }
    },
    "mappings": {
        "properties":{
            "ip_addr": {
                "type": "ip"
            },
            "access_time": {
                "type": "date"
            },
            "address": {
                "type" :"text"
            },
            "name": {
                "type": "keyword"
            }
        }
    }
}

 

3 - 改(会直接覆盖原有的模板配置)

POST http://10.0.0.113:19200/_template/baimei

 

 

{
    "aliases": {
        "K8S": {},
        "BigDataOp": {}
    },
    "index_patterns": [
        "baimei*"
    ],
    "settings": {
        "index": {
            "number_of_shards": 3,
            "number_of_replicas": 0
        }
    },
    "mappings": {
        "properties":{
            "ip_addr": {
                "type": "ip"
            },
            "access_time": {
                "type": "date"
            },
            "address": {
                "type" :"text"
            },
            "name": {
                "type": "keyword"
            }
        }
    }
}

 

4-删除

DELETE  http://10.0.0.113:19200/_template/baimei

 

 


欢迎来撩 : ELK集群汇总

欢迎来撩 : zabbix汇总

欢迎来撩 : ansible汇总

欢迎来撩 : shell 编程从0到1

欢迎来撩 : devops cicd持续集成全程(汇总)

欢迎来撩 : 汇总all

 

欢迎来撩 : 汇总all

白眉大叔

关于白眉大叔linux云计算: 白眉大叔

热门文章