# NOT RUN {
(x <- connect())
body <- '{
"template": "te*",
"settings": {
"number_of_shards": 1
},
"mappings": {
"type1": {
"_source": {
"enabled": false
},
"properties": {
"host_name": {
"type": "keyword"
},
"created_at": {
"type": "date",
"format": "EEE MMM dd HH:mm:ss Z YYYY"
}
}
}
}
}'
index_template_put(x, "template_1", body = body)
# get templates
index_template_get(x)
index_template_get(x, "template_1")
index_template_get(x, c("template_1", "template_2"))
index_template_get(x, "template_*")
## filter path
index_template_get(x, "template_1", filter_path = "*.template")
# template exists
index_template_exists(x, "template_1")
index_template_exists(x, "foobar")
# delete a template
index_template_delete(x, "template_1")
index_template_exists(x, "template_1")
# }
Run the code above in your browser using DataLab