put_template.asciidoc 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. --
  2. :api: put-template
  3. :request: PutIndexTemplateRequest
  4. :response: PutIndexTemplateResponse
  5. --
  6. [id="{upid}-{api}"]
  7. === Put Template API
  8. [id="{upid}-{api}-request"]
  9. ==== Put Index Template Request
  10. A +{request}+ specifies the `name` of a template and `patterns`
  11. which controls whether the template should be applied to the new index.
  12. ["source","java",subs="attributes,callouts,macros"]
  13. --------------------------------------------------
  14. include-tagged::{doc-tests-file}[{api}-request]
  15. --------------------------------------------------
  16. <1> The name of the template
  17. <2> The patterns of the template
  18. ==== Settings
  19. The settings of the template will be applied to the new index whose name matches the
  20. template's patterns.
  21. ["source","java",subs="attributes,callouts,macros"]
  22. --------------------------------------------------
  23. include-tagged::{doc-tests-file}[{api}-request-settings]
  24. --------------------------------------------------
  25. <1> Settings for this template
  26. [[java-rest-high-put-template-request-mappings]]
  27. ==== Mappings
  28. The mapping of the template will be applied to the new index whose name matches the
  29. template's patterns.
  30. ["source","java",subs="attributes,callouts,macros"]
  31. --------------------------------------------------
  32. include-tagged::{doc-tests-file}[{api}-request-mappings-json]
  33. --------------------------------------------------
  34. <1> The mapping, provided as a JSON string
  35. The mapping source can be provided in different ways in addition to the
  36. `String` example shown above:
  37. ["source","java",subs="attributes,callouts,macros"]
  38. --------------------------------------------------
  39. include-tagged::{doc-tests-file}[{api}-request-mappings-map]
  40. --------------------------------------------------
  41. <1> Mapping source provided as a `Map` which gets automatically converted
  42. to JSON format
  43. ["source","java",subs="attributes,callouts,macros"]
  44. --------------------------------------------------
  45. include-tagged::{doc-tests-file}[{api}-request-mappings-xcontent]
  46. --------------------------------------------------
  47. <1> Mapping source provided as an `XContentBuilder` object, the Elasticsearch
  48. built-in helpers to generate JSON content
  49. ==== Aliases
  50. The aliases of the template will define aliasing to the index whose name matches the
  51. template's patterns. A placeholder `{index}` can be used in an alias of a template.
  52. ["source","java",subs="attributes,callouts,macros"]
  53. --------------------------------------------------
  54. include-tagged::{doc-tests-file}[{api}-request-aliases]
  55. --------------------------------------------------
  56. <1> The alias to define
  57. <2> The alias to define with placeholder
  58. ==== Order
  59. In case multiple templates match an index, the orders of matching templates determine
  60. the sequence that settings, mappings, and alias of each matching template is applied.
  61. Templates with lower orders are applied first, and higher orders override them.
  62. ["source","java",subs="attributes,callouts,macros"]
  63. --------------------------------------------------
  64. include-tagged::{doc-tests-file}[{api}-request-order]
  65. --------------------------------------------------
  66. <1> The order of the template
  67. ==== Version
  68. A template can optionally specify a version number which can be used to simplify template
  69. management by external systems.
  70. ["source","java",subs="attributes,callouts,macros"]
  71. --------------------------------------------------
  72. include-tagged::{doc-tests-file}[{api}-request-version]
  73. --------------------------------------------------
  74. <1> The version number of the template
  75. ==== Providing the whole source
  76. The whole source including all of its sections (mappings, settings and aliases)
  77. can also be provided:
  78. ["source","java",subs="attributes,callouts,macros"]
  79. --------------------------------------------------
  80. include-tagged::{doc-tests-file}[{api}-whole-source]
  81. --------------------------------------------------
  82. <1> The source provided as a JSON string. It can also be provided as a `Map`
  83. or an `XContentBuilder`.
  84. ==== Optional arguments
  85. The following arguments can optionally be provided:
  86. ["source","java",subs="attributes,callouts,macros"]
  87. --------------------------------------------------
  88. include-tagged::{doc-tests-file}[{api}-request-create]
  89. --------------------------------------------------
  90. <1> To force to only create a new template; do not overwrite the existing template
  91. ["source","java",subs="attributes,callouts,macros"]
  92. --------------------------------------------------
  93. include-tagged::{doc-tests-file}[{api}-request-masterTimeout]
  94. --------------------------------------------------
  95. <1> Timeout to connect to the master node as a `TimeValue`
  96. <2> Timeout to connect to the master node as a `String`
  97. include::../execution.asciidoc[]
  98. [id="{upid}-{api}-response"]
  99. ==== Put Index Template Response
  100. The returned +{response}+ allows to retrieve information about the
  101. executed operation as follows:
  102. ["source","java",subs="attributes,callouts,macros"]
  103. --------------------------------------------------
  104. include-tagged::{doc-tests-file}[{api}-response]
  105. --------------------------------------------------
  106. <1> Indicates whether all of the nodes have acknowledged the request