component-templates.asciidoc 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. [[cat-component-templates]]
  2. === cat component templates API
  3. ++++
  4. <titleabbrev>cat component templates</titleabbrev>
  5. ++++
  6. .New API reference
  7. [sidebar]
  8. --
  9. For the most up-to-date API details, refer to {api-es}/group/endpoint-cat[Compact and aligned text (CAT) APIs]..
  10. --
  11. [IMPORTANT]
  12. ====
  13. cat APIs are only intended for human consumption using the command line or {kib}
  14. console. They are _not_ intended for use by applications. For application
  15. consumption, use the <<getting-component-templates,get component template API>>.
  16. ====
  17. Returns information about <<indices-component-template,component templates>> in
  18. a cluster. Component templates are building blocks for constructing
  19. <<index-templates,index templates>> that specify index <<mapping,mappings>>,
  20. <<index-modules-settings,settings>>, and <<aliases,aliases>>.
  21. [[cat-component-templates-api-request]]
  22. ==== {api-request-title}
  23. `GET /_cat/component_templates/<template_name>`
  24. `GET /_cat/component_templates`
  25. [[cat-component-templates-api-prereqs]]
  26. ==== {api-prereq-title}
  27. * If the {es} {security-features} are enabled, you must have the `monitor` or
  28. `manage` <<privileges-list-cluster,cluster privilege>> to use this API.
  29. [[cat-component-templates-path-params]]
  30. ==== {api-path-parms-title}
  31. `<template_name>`::
  32. (Optional, string) The name of the component template to return. Accepts
  33. wildcard expressions. If omitted, all component templates are returned.
  34. [[cat-component-templates-query-params]]
  35. ==== {api-query-parms-title}
  36. include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=http-format]
  37. include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=cat-h]
  38. include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=help]
  39. include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=local]
  40. include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=master-timeout]
  41. include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=cat-s]
  42. include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=cat-v]
  43. [[cat-component-templates-api-example]]
  44. ==== {api-examples-title}
  45. ////
  46. [source,console]
  47. ----
  48. PUT _component_template/my-template-1
  49. {
  50. "template": {
  51. "settings": {
  52. "number_of_shards": 1
  53. }
  54. }
  55. }
  56. PUT _component_template/my-template-2
  57. {
  58. "template": {
  59. "mappings": {
  60. "_source": {
  61. "enabled": false
  62. },
  63. "properties": {
  64. "host_name": {
  65. "type": "keyword"
  66. },
  67. "created_at": {
  68. "type": "date"
  69. }
  70. }
  71. }
  72. }
  73. }
  74. PUT _index_template/my-index-template
  75. {
  76. "index_patterns": [
  77. "my-index*"
  78. ],
  79. "composed_of": [
  80. "my-template-1",
  81. "my-template-2"
  82. ]
  83. }
  84. ----
  85. ////
  86. [source,console]
  87. ----
  88. GET _cat/component_templates/my-template-*?v=true&s=name
  89. ----
  90. // TEST[continued]
  91. The API returns the following response:
  92. [source,txt]
  93. ----
  94. name version alias_count mapping_count settings_count metadata_count included_in
  95. my-template-1 0 0 1 0 [my-index-template]
  96. my-template-2 0 3 0 0 [my-index-template]
  97. ----
  98. // TESTRESPONSE[s/\*/\\*/ s/\[/\\[/ s/\]/\\]/ non_json]
  99. ////
  100. [source,console]
  101. ----
  102. DELETE _index_template/my-index-template
  103. DELETE _component_template/my-template-1
  104. DELETE _component_template/my-template-2
  105. ----
  106. // TEST[continued]
  107. ////