templates.asciidoc 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. [[cat-templates-path-params]]
  13. ==== {api-path-parms-title}
  14. `<template_name>`::
  15. (Optional, string) Comma-separated list of index template names used to limit
  16. the request. Accepts wildcard expressions.
  17. [[cat-templates-query-params]]
  18. ==== {api-query-parms-title}
  19. include::{docdir}/rest-api/common-parms.asciidoc[tag=http-format]
  20. include::{docdir}/rest-api/common-parms.asciidoc[tag=cat-h]
  21. include::{docdir}/rest-api/common-parms.asciidoc[tag=help]
  22. include::{docdir}/rest-api/common-parms.asciidoc[tag=local]
  23. include::{docdir}/rest-api/common-parms.asciidoc[tag=master-timeout]
  24. include::{docdir}/rest-api/common-parms.asciidoc[tag=cat-s]
  25. include::{docdir}/rest-api/common-parms.asciidoc[tag=cat-v]
  26. [[cat-templates-api-example]]
  27. ==== {api-examples-title}
  28. [source,console]
  29. --------------------------------------------------
  30. GET /_cat/templates?v&s=name
  31. --------------------------------------------------
  32. // TEST[s/templates/templates\/template*/]
  33. // TEST[s/^/PUT _template\/template0\n{"index_patterns": "te*", "order": 0}\n/]
  34. // TEST[s/^/PUT _template\/template1\n{"index_patterns": "tea*", "order": 1}\n/]
  35. // TEST[s/^/PUT _template\/template2\n{"index_patterns": "teak*", "order": 2, "version": 7}\n/]
  36. // The substitutions do two things:
  37. // 1. Filter the response to just templates matching the te* pattern
  38. // so that we only get the templates we expect regardless of which
  39. // templates exist. If xpack is installed there will be unexpected
  40. // templates.
  41. // 2. Create some templates to expect in the response.
  42. The API returns the following response:
  43. [source,txt]
  44. --------------------------------------------------
  45. name index_patterns order version
  46. template0 [te*] 0
  47. template1 [tea*] 1
  48. template2 [teak*] 2 7
  49. --------------------------------------------------
  50. // TESTRESPONSE[s/\*/\\*/ s/\[/\\[/ s/\]/\\]/ non_json]