templates.asciidoc 2.6 KB

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