component-templates.asciidoc 3.1 KB

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