simulate-index.asciidoc 5.1 KB

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