templates.asciidoc 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. [[cat-templates]]
  2. === cat templates API
  3. ++++
  4. <titleabbrev>cat templates</titleabbrev>
  5. ++++
  6. [IMPORTANT]
  7. ====
  8. cat APIs are only intended for human consumption using the command line or {kib}
  9. console. They are _not_ intended for use by applications. For application
  10. consumption, use the <<indices-get-template,get index template API>>.
  11. ====
  12. Returns information about <<index-templates,index templates>> in a cluster.
  13. You can use index templates to apply <<index-modules-settings,index settings>>
  14. and <<mapping,field mappings>> to new indices at creation.
  15. [[cat-templates-api-request]]
  16. ==== {api-request-title}
  17. `GET /_cat/templates/<template_name>`
  18. `GET /_cat/templates`
  19. [[cat-templates-api-prereqs]]
  20. ==== {api-prereq-title}
  21. * If the {es} {security-features} are enabled, you must have the `monitor` or
  22. `manage` <<privileges-list-cluster,cluster privilege>> to use this API.
  23. [[cat-templates-path-params]]
  24. ==== {api-path-parms-title}
  25. `<template_name>`::
  26. (Optional, string) The name of the template to return. Accepts wildcard
  27. expressions. If omitted, all templates are returned.
  28. [[cat-templates-query-params]]
  29. ==== {api-query-parms-title}
  30. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=http-format]
  31. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=cat-h]
  32. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=help]
  33. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=local]
  34. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=master-timeout]
  35. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=cat-s]
  36. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=cat-v]
  37. [[cat-templates-api-example]]
  38. ==== {api-examples-title}
  39. [source,console]
  40. ----
  41. GET _cat/templates/my-template-*?v=true&s=name
  42. ----
  43. // TEST[s/^/PUT _index_template\/my-template-0\n{"index_patterns": "te*", "priority": 500}\n/]
  44. // TEST[s/^/PUT _index_template\/my-template-1\n{"index_patterns": "tea*", "priority": 501}\n/]
  45. // TEST[s/^/PUT _index_template\/my-template-2\n{"index_patterns": "teak*", "priority": 502, "version": 7}\n/]
  46. The API returns the following response:
  47. [source,txt]
  48. ----
  49. name index_patterns order version composed_of
  50. my-template-0 [te*] 500 []
  51. my-template-1 [tea*] 501 []
  52. my-template-2 [teak*] 502 7 []
  53. ----
  54. // TESTRESPONSE[s/\*/\\*/ s/\[/\\[/ s/\]/\\]/ non_json]
  55. ////
  56. [source,console]
  57. ----
  58. DELETE _index_template/my-template-0
  59. DELETE _index_template/my-template-1
  60. DELETE _index_template/my-template-2
  61. ----
  62. // TEST[continued]
  63. ////