templates.asciidoc 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. [[cat-templates]]
  2. === cat templates API
  3. ++++
  4. <titleabbrev>cat templates</titleabbrev>
  5. ++++
  6. Returns information about <<indices-templates,index templates>> in a cluster.
  7. You can use index templates to apply <<index-modules-settings,index settings>>
  8. and <<mapping,field mappings>> to new indices at creation.
  9. [[cat-templates-api-request]]
  10. ==== {api-request-title}
  11. `GET /_cat/templates/<template_name>`
  12. `GET /_cat/templates`
  13. [[cat-templates-path-params]]
  14. ==== {api-path-parms-title}
  15. `<template_name>`::
  16. (Optional, string) Comma-separated list of index template names used to limit
  17. the request. Accepts wildcard expressions.
  18. [[cat-templates-query-params]]
  19. ==== {api-query-parms-title}
  20. include::{docdir}/rest-api/common-parms.asciidoc[tag=http-format]
  21. include::{docdir}/rest-api/common-parms.asciidoc[tag=cat-h]
  22. include::{docdir}/rest-api/common-parms.asciidoc[tag=help]
  23. include::{docdir}/rest-api/common-parms.asciidoc[tag=local]
  24. include::{docdir}/rest-api/common-parms.asciidoc[tag=master-timeout]
  25. include::{docdir}/rest-api/common-parms.asciidoc[tag=cat-s]
  26. include::{docdir}/rest-api/common-parms.asciidoc[tag=cat-v]
  27. [[cat-templates-api-example]]
  28. ==== {api-examples-title}
  29. [source,console]
  30. --------------------------------------------------
  31. GET /_cat/templates?v&s=name
  32. --------------------------------------------------
  33. // TEST[s/templates/templates\/template*/]
  34. // TEST[s/^/PUT _template\/template0\n{"index_patterns": "te*", "order": 0}\n/]
  35. // TEST[s/^/PUT _template\/template1\n{"index_patterns": "tea*", "order": 1}\n/]
  36. // TEST[s/^/PUT _template\/template2\n{"index_patterns": "teak*", "order": 2, "version": 7}\n/]
  37. // The substitutions do two things:
  38. // 1. Filter the response to just templates matching the te* pattern
  39. // so that we only get the templates we expect regardless of which
  40. // templates exist. If xpack is installed there will be unexpected
  41. // templates.
  42. // 2. Create some templates to expect in the response.
  43. The API returns the following response:
  44. [source,txt]
  45. --------------------------------------------------
  46. name index_patterns order version
  47. template0 [te*] 0
  48. template1 [tea*] 1
  49. template2 [teak*] 2 7
  50. --------------------------------------------------
  51. // TESTRESPONSE[s/\*/\\*/ s/\[/\\[/ s/\]/\\]/ non_json]
  52. //////////////////////////
  53. [source,console]
  54. --------------------------------------------------
  55. DELETE /_template/template0
  56. DELETE /_template/template1
  57. DELETE /_template/template2
  58. --------------------------------------------------
  59. // TEST[continued]
  60. //////////////////////////