2016-09-20 04:40:23 -04:00
|
|
|
[[cat-templates]]
|
|
|
|
== cat templates
|
|
|
|
|
|
|
|
The `templates` command provides information about existing templates.
|
|
|
|
|
2017-05-03 20:58:23 -04:00
|
|
|
[source,js]
|
2016-09-20 04:40:23 -04:00
|
|
|
--------------------------------------------------
|
2017-05-03 20:58:23 -04:00
|
|
|
GET /_cat/templates?v&s=name
|
2016-09-20 04:40:23 -04:00
|
|
|
--------------------------------------------------
|
2017-05-03 20:58:23 -04:00
|
|
|
// CONSOLE
|
2018-06-18 12:06:42 -04:00
|
|
|
// TEST[s/templates/templates\/template*/]
|
2017-05-03 20:58:23 -04:00
|
|
|
// TEST[s/^/PUT _template\/template0\n{"index_patterns": "te*", "order": 0}\n/]
|
|
|
|
// TEST[s/^/PUT _template\/template1\n{"index_patterns": "tea*", "order": 1}\n/]
|
|
|
|
// TEST[s/^/PUT _template\/template2\n{"index_patterns": "teak*", "order": 2, "version": 7}\n/]
|
2018-06-18 12:06:42 -04:00
|
|
|
// The substitions do two things:
|
|
|
|
// 1. Filter the response to just templates matching the te* pattern
|
|
|
|
// so that we only get the templates we expect regardless of which
|
|
|
|
// templates exist. If xpack is installed there will be unexpected
|
|
|
|
// templates.
|
|
|
|
// 2. Create some templates to expect in the response.
|
2017-05-03 20:58:23 -04:00
|
|
|
|
|
|
|
which looks like
|
|
|
|
|
|
|
|
[source,txt]
|
|
|
|
--------------------------------------------------
|
|
|
|
name index_patterns order version
|
|
|
|
template0 [te*] 0
|
|
|
|
template1 [tea*] 1
|
|
|
|
template2 [teak*] 2 7
|
|
|
|
--------------------------------------------------
|
|
|
|
// TESTRESPONSE[s/\*/\\*/ s/\[/\\[/ s/\]/\\]/ _cat]
|
2016-09-20 04:40:23 -04:00
|
|
|
|
|
|
|
The output shows that there are three existing templates,
|
2017-02-16 14:41:42 -05:00
|
|
|
with template2 having a version value.
|
2016-09-20 04:40:23 -04:00
|
|
|
|
|
|
|
The endpoint also supports giving a template name or pattern in the url
|
|
|
|
to filter the results, for example `/_cat/templates/template*` or
|
|
|
|
`/_cat/templates/template0`.
|