templates.asciidoc 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. [[cat-templates]]
  2. === cat templates API
  3. ++++
  4. <titleabbrev>cat templates</titleabbrev>
  5. ++++
  6. Returns information about <<index-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. `GET /_cat/templates`
  13. [[cat-templates-api-prereqs]]
  14. ==== {api-prereq-title}
  15. * If the {es} {security-features} are enabled, you must have the `monitor` or
  16. `manage` <<privileges-list-cluster,cluster privilege>> to use this API.
  17. [[cat-templates-path-params]]
  18. ==== {api-path-parms-title}
  19. `<template_name>`::
  20. (Optional, string) Comma-separated list of index template names used to limit
  21. the request. Accepts wildcard expressions.
  22. [[cat-templates-query-params]]
  23. ==== {api-query-parms-title}
  24. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=http-format]
  25. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=cat-h]
  26. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=help]
  27. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=local]
  28. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=master-timeout]
  29. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=cat-s]
  30. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=cat-v]
  31. [[cat-templates-api-example]]
  32. ==== {api-examples-title}
  33. [source,console]
  34. ----
  35. GET _cat/templates/my-template-*?v=true&s=name
  36. ----
  37. // TEST[s/^/PUT _index_template\/my-template-0\n{"index_patterns": "te*", "priority": 200}\n/]
  38. // TEST[s/^/PUT _index_template\/my-template-1\n{"index_patterns": "tea*", "priority": 201}\n/]
  39. // TEST[s/^/PUT _index_template\/my-template-2\n{"index_patterns": "teak*", "priority": 202, "version": 7}\n/]
  40. The API returns the following response:
  41. [source,txt]
  42. ----
  43. name index_patterns order version composed_of
  44. my-template-0 [te*] 200 []
  45. my-template-1 [tea*] 201 []
  46. my-template-2 [teak*] 202 7 []
  47. ----
  48. // TESTRESPONSE[s/\*/\\*/ s/\[/\\[/ s/\]/\\]/ non_json]
  49. ////
  50. [source,console]
  51. ----
  52. DELETE _index_template/my-template-0
  53. DELETE _index_template/my-template-1
  54. DELETE _index_template/my-template-2
  55. ----
  56. // TEST[continued]
  57. ////