simulate-index.asciidoc 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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 <<indices-templates, index template>>.
  9. ////
  10. [source,console]
  11. --------------------------------------------------
  12. PUT _index_template/template_1
  13. {
  14. "index_patterns": ["myindex*"],
  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/myindex-1
  32. --------------------------------------------------
  33. [[simulate-index-api-request]]
  34. ==== {api-request-title}
  35. `POST /_index_template/_simulate_index/<index>`
  36. [[simulate-index-api-path-params]]
  37. ==== {api-path-parms-title}
  38. `<index>`::
  39. (Required, string)
  40. Name of the index to simulate.
  41. [[simulate-index-api-query-params]]
  42. ==== {api-query-parms-title}
  43. ////
  44. `cause`::
  45. (Optional, string) The reason for running the simulation.
  46. ////
  47. include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=master-timeout]
  48. [role="child_attributes"]
  49. [[simulate-index-api-response-body]]
  50. ==== {api-response-body-title}
  51. `overlapping`::
  52. (array) Any templates that also matched the index but were superseded by a higher-priority template.
  53. Response includes an empty array if there are no overlapping templates.
  54. +
  55. .Properties of `overlapping`
  56. [%collapsible%open]
  57. ====
  58. `name`::
  59. (string) Name of the superseded template.
  60. `index_patterns`::
  61. (array) Index patterns that the superseded template applies to.
  62. ====
  63. `template`::
  64. (object)
  65. The settings, mappings, and aliases that would be applied to the index.
  66. +
  67. .Properties of `template`
  68. [%collapsible%open]
  69. ====
  70. include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=aliases]
  71. +
  72. Response includes an empty object if no aliases would be applied.
  73. include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=mappings]
  74. +
  75. Omitted from the response if no mappings would be applied.
  76. include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=settings]
  77. +
  78. Response includes an empty object if no settings would be applied.
  79. ====
  80. [[simulate-index-api-example]]
  81. ==== {api-examples-title}
  82. The following example shows the configuration that would be applied to `myindex-1` by
  83. an existing template.
  84. [source,console]
  85. --------------------------------------------------
  86. PUT /_component_template/ct1 <1>
  87. {
  88. "template": {
  89. "settings": {
  90. "index.number_of_shards": 2
  91. }
  92. }
  93. }
  94. PUT /_component_template/ct2 <2>
  95. {
  96. "template": {
  97. "settings": {
  98. "index.number_of_replicas": 0
  99. },
  100. "mappings": {
  101. "properties": {
  102. "@timestamp": {
  103. "type": "date"
  104. }
  105. }
  106. }
  107. }
  108. }
  109. PUT /_index_template/final-template <3>
  110. {
  111. "index_patterns": ["myindex*"],
  112. "composed_of": ["ct1", "ct2"],
  113. "priority": 5
  114. }
  115. POST /_index_template/_simulate_index/myindex-1 <4>
  116. --------------------------------------------------
  117. <1> Create a component template (`ct1`) that sets the number of shards to 2
  118. <2> Create a second component template (`ct2`) that sets the number of replicas to 0 and defines a mapping
  119. <3> Create an index template (`final-template`) that uses the component templates
  120. <4> Show the configuration that would be applied to `myindex-1`
  121. The response shows the index settings, mappings, and aliases applied by the `final-template`:
  122. [source,console-result]
  123. ---------------------------------------------------------
  124. {
  125. "template" : {
  126. "settings" : {
  127. "index" : {
  128. "number_of_shards" : "2",
  129. "number_of_replicas" : "0"
  130. }
  131. },
  132. "mappings" : {
  133. "properties" : {
  134. "@timestamp" : {
  135. "type" : "date"
  136. }
  137. }
  138. },
  139. "aliases" : { }
  140. },
  141. "overlapping" : [
  142. {
  143. "name" : "template_1",
  144. "index_patterns" : [
  145. "myindex*"
  146. ]
  147. }
  148. ]
  149. }
  150. ---------------------------------------------------------