aliases.asciidoc 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. [[indices-aliases]]
  2. === Aliases API
  3. ++++
  4. <titleabbrev>Aliases</titleabbrev>
  5. ++++
  6. Performs one or more <<alias,alias>> actions in a single atomic operation.
  7. [source,console]
  8. ----
  9. POST /_aliases
  10. {
  11. "actions" : [
  12. { "add" : { "index" : "my-index-000001", "alias" : "alias1" } }
  13. ]
  14. }
  15. ----
  16. // TEST[setup:my_index]
  17. [[indices-aliases-api-request]]
  18. ==== {api-request-title}
  19. `POST /_aliases`
  20. [[indices-aliases-api-prereqs]]
  21. ==== {api-prereq-title}
  22. * If the {es} {security-features} are enabled, you must have the following
  23. <<privileges-list-indices,index privileges>>:
  24. ** To use the `add` or `remove` action, you must have the `manage` index
  25. privilege for both the index and index alias.
  26. ** To use the `remove_index` action, you must have the `manage` index privilege
  27. for the index.
  28. [[indices-aliases-api-desc]]
  29. ==== {api-description-title}
  30. APIs in Elasticsearch accept an index name when working against a
  31. specific index, and several indices when applicable. The index aliases
  32. API allows aliasing an index with a name, with all APIs automatically
  33. converting the alias name to the actual index name. An alias can also be
  34. mapped to more than one index, and when specifying it, the alias will
  35. automatically expand to the aliased indices. An alias can also be
  36. associated with a filter that will automatically be applied when
  37. searching, and routing values. An alias cannot have the same name as an index.
  38. [[indices-aliases-api-query-params]]
  39. ==== {api-query-parms-title}
  40. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
  41. [[indices-aliases-api-request-body]]
  42. ==== {api-request-body-title}
  43. `actions`::
  44. +
  45. --
  46. (Required, array of actions)
  47. Set of actions to perform.
  48. Valid actions include:
  49. `add`::
  50. Adds an alias to an index.
  51. `remove`::
  52. Removes an alias from an index.
  53. `remove_index`::
  54. Deletes a concrete index, similar to the <<indices-delete-index, delete index
  55. API>>. Attempts to remove an index alias will fail.
  56. You can perform these actions on alias objects.
  57. Valid parameters for alias objects include:
  58. `index`::
  59. (String)
  60. Wildcard expression of index names
  61. used to perform the action.
  62. +
  63. If the `indices` parameter is not specified,
  64. this parameter is required.
  65. +
  66. NOTE: You cannot add <<data-streams,data streams>> to an index alias.
  67. `indices`::
  68. (Array)
  69. Array of index names
  70. used to perform the action.
  71. +
  72. If the `index` parameter is not specified,
  73. this parameter is required.
  74. +
  75. NOTE: You cannot add <<data-streams,data streams>> to an index alias.
  76. `alias`::
  77. (String)
  78. Comma-separated list or wildcard expression of index alias names to add, remove,
  79. or delete. Supports <<date-math-index-names,date math>>.
  80. +
  81. If the `aliases` parameter is not specified,
  82. this parameter is required for the `add` or `remove` action.
  83. `aliases`::
  84. (Array of strings)
  85. Array of index alias names to add, remove, or delete. Supports
  86. <<date-math-index-names,date math>>.
  87. +
  88. If the `alias` parameter is not specified, this parameter is required for the
  89. `add` or `remove` action.
  90. `filter`::
  91. (Optional, query object)
  92. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-alias-filter]
  93. +
  94. See <<filter-alias>> for an example.
  95. `is_hidden`::
  96. (Optional, Boolean)
  97. If `true`, the alias will be excluded from wildcard expressions by default,
  98. unless overridden in the request using the `expand_wildcards` parameter,
  99. similar to <<index-hidden,hidden indices>>. This property must be set to the
  100. same value on all indices that share an alias. Defaults to `false`.
  101. `must_exist`::
  102. (Optional, Boolean)
  103. If `true`, the alias to remove must exist. Defaults to `false`.
  104. `is_write_index`::
  105. (Optional, Boolean)
  106. If `true`, assigns the index as an alias's write index.
  107. Defaults to `false`.
  108. +
  109. An alias can have one write index at a time.
  110. +
  111. See <<write-index>> for an example.
  112. +
  113. [IMPORTANT]
  114. ====
  115. Aliases that do not explicitly set `is_write_index: true` for an index, and
  116. only reference one index, will have that referenced index behave as if it is the write index
  117. until an additional index is referenced. At that point, there will be no write index and
  118. writes will be rejected.
  119. ====
  120. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=routing]
  121. +
  122. See <<alias-routing>> for an example.
  123. `index_routing`::
  124. (Optional, string)
  125. Custom <<mapping-routing-field, routing value>> used
  126. for the alias's indexing operations.
  127. +
  128. See <<alias-routing>> for an example.
  129. `search_routing`::
  130. (Optional, string)
  131. Custom <<mapping-routing-field, routing value>> used
  132. for the alias's search operations.
  133. +
  134. See <<alias-routing>> for an example.
  135. --