simulate-index.asciidoc 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. [[indices-simulate-index]]
  2. === Simulate index API
  3. ++++
  4. <titleabbrev>Simulate index</titleabbrev>
  5. ++++
  6. Returns the index configuration that would be applied to the specified index from an
  7. existing <<index-templates, index template>>.
  8. ////
  9. [source,console]
  10. --------------------------------------------------
  11. PUT _index_template/template_1
  12. {
  13. "index_patterns": ["my-index-*"],
  14. "template": {
  15. "settings": {
  16. "number_of_shards": 1
  17. }
  18. }
  19. }
  20. --------------------------------------------------
  21. // TESTSETUP
  22. [source,console]
  23. --------------------------------------------------
  24. DELETE _index_template/*
  25. --------------------------------------------------
  26. // TEARDOWN
  27. ////
  28. [source,console]
  29. --------------------------------------------------
  30. POST /_index_template/_simulate_index/my-index-000001
  31. --------------------------------------------------
  32. [[simulate-index-api-request]]
  33. ==== {api-request-title}
  34. `POST /_index_template/_simulate_index/<index>`
  35. [[simulate-index-api-prereqs]]
  36. ==== {api-prereq-title}
  37. * If the {es} {security-features} are enabled, you must have the
  38. `manage_index_templates` or `manage` <<privileges-list-cluster,cluster
  39. privilege>> to use this API.
  40. [[simulate-index-api-path-params]]
  41. ==== {api-path-parms-title}
  42. `<index>`::
  43. (Required, string)
  44. Name of the index to simulate.
  45. [[simulate-index-api-query-params]]
  46. ==== {api-query-parms-title}
  47. ////
  48. `cause`::
  49. (Optional, string) The reason for running the simulation.
  50. ////
  51. include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=master-timeout]
  52. `include_defaults`::
  53. (Optional, Boolean) Functionality in preview:[]. If `true`, return all default settings in the response.
  54. Defaults to `false`.
  55. [role="child_attributes"]
  56. [[simulate-index-api-response-body]]
  57. ==== {api-response-body-title}
  58. `overlapping`::
  59. (array) Any templates that also matched the index but were superseded by a higher-priority template.
  60. Response includes an empty array if there are no overlapping templates.
  61. +
  62. .Properties of `overlapping`
  63. [%collapsible%open]
  64. ====
  65. `name`::
  66. (string) Name of the superseded template.
  67. `index_patterns`::
  68. (array) Index patterns that the superseded template applies to.
  69. ====
  70. `template`::
  71. (object)
  72. The settings, mappings, and aliases that would be applied to the index.
  73. +
  74. .Properties of `template`
  75. [%collapsible%open]
  76. ====
  77. `aliases`::
  78. (object) Aliases for the index. If no aliases apply, the response returns an
  79. empty `aliases` object.
  80. +
  81. =====
  82. `<alias>`::
  83. (object) The key is the alias name. The object body contains options for the
  84. alias.
  85. +
  86. .Properties of `<alias>`
  87. [%collapsible%open]
  88. ======
  89. `filter`::
  90. (<<query-dsl,Query DSL object>>) Query used to limit documents the alias can
  91. access.
  92. `index_routing`::
  93. (string) Value used to route indexing operations to a specific shard. This
  94. overwrites the `routing` value for indexing operations.
  95. `is_hidden`::
  96. (Boolean) If `true`, the alias is <<multi-hidden,hidden>>.
  97. `is_write_index`::
  98. (Boolean) If `true`, the index is the <<write-index,write index>> for the alias.
  99. `routing`::
  100. (string) Value used to route indexing and search operations to a specific shard.
  101. `search_routing`::
  102. (string) Value used to route search operations to a specific shard. This
  103. overwrites the `routing` value for search operations.
  104. ======
  105. =====
  106. include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=mappings]
  107. +
  108. Omitted from the response if no mappings would be applied.
  109. include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=settings]
  110. +
  111. Response includes an empty object if no settings would be applied.
  112. ====
  113. [[simulate-index-api-example]]
  114. ==== {api-examples-title}
  115. The following example shows the configuration that would be applied to `my-index-000001` by
  116. an existing template.
  117. [source,console]
  118. --------------------------------------------------
  119. PUT /_component_template/ct1 <1>
  120. {
  121. "template": {
  122. "settings": {
  123. "index.number_of_shards": 2
  124. }
  125. }
  126. }
  127. PUT /_component_template/ct2 <2>
  128. {
  129. "template": {
  130. "settings": {
  131. "index.number_of_replicas": 0
  132. },
  133. "mappings": {
  134. "properties": {
  135. "@timestamp": {
  136. "type": "date"
  137. }
  138. }
  139. }
  140. }
  141. }
  142. PUT /_index_template/final-template <3>
  143. {
  144. "index_patterns": ["my-index-*"],
  145. "composed_of": ["ct1", "ct2"],
  146. "priority": 5
  147. }
  148. POST /_index_template/_simulate_index/my-index-000001 <4>
  149. --------------------------------------------------
  150. <1> Create a component template (`ct1`) that sets the number of shards to 2
  151. <2> Create a second component template (`ct2`) that sets the number of replicas to 0 and defines a mapping
  152. <3> Create an index template (`final-template`) that uses the component templates
  153. <4> Show the configuration that would be applied to `my-index-000001`
  154. The response shows the index settings, mappings, and aliases applied by the `final-template`:
  155. [source,console-result]
  156. ---------------------------------------------------------
  157. {
  158. "template" : {
  159. "settings" : {
  160. "index" : {
  161. "number_of_shards" : "2",
  162. "number_of_replicas" : "0",
  163. "routing" : {
  164. "allocation" : {
  165. "include" : {
  166. "_tier_preference" : "data_content"
  167. }
  168. }
  169. }
  170. }
  171. },
  172. "mappings" : {
  173. "properties" : {
  174. "@timestamp" : {
  175. "type" : "date"
  176. }
  177. }
  178. },
  179. "aliases" : { }
  180. },
  181. "overlapping" : [
  182. {
  183. "name" : "template_1",
  184. "index_patterns" : [
  185. "my-index-*"
  186. ]
  187. }
  188. ]
  189. }
  190. ---------------------------------------------------------