aliases.asciidoc 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. [[indices-aliases]]
  2. === Aliases API
  3. ++++
  4. <titleabbrev>Aliases</titleabbrev>
  5. ++++
  6. Performs one or more <<aliases,alias>> actions in a single atomic operation.
  7. [source,console]
  8. ----
  9. POST _aliases
  10. {
  11. "actions": [
  12. {
  13. "add": {
  14. "index": "my-data-stream",
  15. "alias": "my-alias"
  16. }
  17. }
  18. ]
  19. }
  20. ----
  21. // TEST[setup:my_data_stream]
  22. // TEST[teardown:data_stream_cleanup]
  23. [[indices-aliases-api-request]]
  24. ==== {api-request-title}
  25. `POST _aliases`
  26. [[indices-aliases-api-prereqs]]
  27. ==== {api-prereq-title}
  28. * If the {es} {security-features} are enabled, you must have the following
  29. <<privileges-list-indices,index privileges>>:
  30. ** To use the `add` or `remove` action, you must have the `manage` index
  31. privilege for the alias and its data streams or indices.
  32. ** To use the `remove_index` action, you must have the `manage` index privilege
  33. for the index.
  34. [[indices-aliases-api-query-params]]
  35. ==== {api-query-parms-title}
  36. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
  37. [role="child_attributes"]
  38. [[indices-aliases-api-request-body]]
  39. ==== {api-request-body-title}
  40. `actions`::
  41. (Required, array of objects) Actions to perform.
  42. +
  43. .Properties of `actions` objects
  44. [%collapsible%open]
  45. ====
  46. `<action>`::
  47. (Required, object) The key is the action type. At least one action is required.
  48. +
  49. .Valid `<action>` keys
  50. [%collapsible%open]
  51. =====
  52. `add`::
  53. Adds a data stream or index to an alias. If the alias doesn't exist, the `add`
  54. action creates it.
  55. `remove`::
  56. Removes a data stream or index from an alias.
  57. `remove_index`::
  58. Deletes an index. You cannot use this action on aliases or data streams.
  59. =====
  60. +
  61. The object body contains options for the alias. Supports an empty object.
  62. +
  63. .Properties of `<action>`
  64. [%collapsible%open]
  65. =====
  66. `alias`::
  67. (Required*, string) Alias for the action. Index alias names support
  68. <<api-date-math-index-names,date math>>. If `aliases` is not specified, the `add`
  69. and `remove` actions require this parameter. For the `remove` action, this
  70. parameter supports wildcards (`*`). The `remove_index` action doesn't support
  71. this parameter.
  72. `aliases`::
  73. (Required*, array of strings) Aliases for the action. Index alias names support
  74. <<api-date-math-index-names,date math>>. If `alias` is not specified, the `add` and
  75. `remove` actions require this parameter. For the `remove` action, this parameter
  76. supports wildcards (`*`). The `remove_index` action doesn't support this
  77. parameter.
  78. // tag::alias-options[]
  79. `filter`::
  80. (Optional, <<query-dsl,Query DSL object>> Query used to limit documents the
  81. alias can access.
  82. // end::alias-options[]
  83. +
  84. Only the `add` action supports this parameter.
  85. `index`::
  86. (Required*, string) Data stream or index for the action. Supports wildcards
  87. (`*`). If `indices` is not specified, this parameter is required. For the `add`
  88. and `remove_index` actions, wildcard patterns that match both data streams and
  89. indices return an error.
  90. `indices`::
  91. (Required*, array of strings) Data streams or indices for the action. Supports
  92. wildcards (`*`). If `index` is not specified, this parameter is required. For
  93. the `add` and `remove_index` actions, wildcard patterns that match both data
  94. streams and indices return an error.
  95. // tag::alias-options[]
  96. `index_routing`::
  97. (Optional, string) Value used to route indexing operations to a specific shard.
  98. If specified, this overwrites the `routing` value for indexing operations. Data
  99. stream aliases don't support this parameter.
  100. // end::alias-options[]
  101. +
  102. Only the `add` action supports this parameter.
  103. // tag::alias-options[]
  104. `is_hidden`::
  105. (Optional, Boolean) If `true`, the alias is <<multi-hidden,hidden>>. Defaults to
  106. `false`. All data streams or indices for the alias must have the same
  107. `is_hidden` value.
  108. // end::alias-options[]
  109. +
  110. Only the `add` action supports this parameter.
  111. // tag::alias-options[]
  112. `is_write_index`::
  113. (Optional, Boolean) If `true`, sets the write index or data stream for the
  114. alias.
  115. +
  116. // tag::write-index-defaults[]
  117. If an alias points to multiple indices or data streams and `is_write_index`
  118. isn't set, the alias rejects write requests. If an index alias points to one
  119. index and `is_write_index` isn't set, the index automatically acts as the write
  120. index. Data stream aliases don't automatically set a write data stream, even if
  121. the alias points to one data stream.
  122. // end::write-index-defaults[]
  123. // end::alias-options[]
  124. +
  125. Only the `add` action supports this parameter.
  126. // tag::alias-options[]
  127. `must_exist`::
  128. (Optional, Boolean)
  129. Affects the behavior when attempting to remove an alias which does not exist.
  130. If `true`, removing an alias which does not exist will cause all actions to fail.
  131. If `false`, removing an alias which does not exist will only cause that removal to fail.
  132. Defaults to `false`.
  133. // end::alias-options[]
  134. +
  135. Only the `remove` action supports this parameter.
  136. // tag::alias-options[]
  137. `routing`::
  138. (Optional, string) Value used to route indexing and search operations to a
  139. specific shard. Data stream aliases don't support this parameter.
  140. // end::alias-options[]
  141. +
  142. Only the `add` action supports this parameter.
  143. // tag::alias-options[]
  144. `search_routing`::
  145. (Optional, string) Value used to route search operations to a specific shard. If
  146. specified, this overwrites the `routing` value for search operations. Data
  147. stream aliases don't support this parameter.
  148. // end::alias-options[]
  149. +
  150. Only the `add` action supports this parameter.
  151. =====
  152. ====
  153. [role="child_attributes"]
  154. [[indices-aliases-api-response-body]]
  155. ==== {api-response-body-title}
  156. `acknowledged`::
  157. (Boolean)
  158. If `true`, the request received a response from the master node within the
  159. `timeout` period.
  160. `errors`::
  161. (Boolean)
  162. If `true`, at least one of the requested actions failed.
  163. `action_results`::
  164. (Optional, array of objects) Results for each requested action.
  165. +
  166. .Properties of `action_results` objects
  167. [%collapsible%open]
  168. ====
  169. `action`::
  170. (object)
  171. Description of the associated action request.
  172. +
  173. .Properties of `action` object
  174. [%collapsible%open]
  175. =====
  176. `type`::
  177. (string) The type of the associated action, one of `add`, `remove`, or `remove_index`.
  178. `indices`::
  179. (array of strings) List of indices in the associated action.
  180. `aliases`::
  181. (array of strings) List of aliases in the associated action.
  182. =====
  183. `status`::
  184. (integer) HTTP status code returned for the action.
  185. `error`::
  186. (Optional, object) Contains additional information about the failed action.
  187. +
  188. Only present if the action failed.
  189. ====