163 lines
4.6 KiB
Plaintext
163 lines
4.6 KiB
Plaintext
[[indices-aliases]]
|
|
=== Aliases API
|
|
++++
|
|
<titleabbrev>Aliases</titleabbrev>
|
|
++++
|
|
|
|
Performs one or more <<alias,alias>> actions in a single atomic operation.
|
|
|
|
[source,console]
|
|
----
|
|
POST _aliases
|
|
{
|
|
"actions": [
|
|
{
|
|
"add": {
|
|
"index": "my-data-stream",
|
|
"alias": "my-alias"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
----
|
|
// TEST[setup:my_data_stream]
|
|
// TEST[teardown:data_stream_cleanup]
|
|
|
|
[[indices-aliases-api-request]]
|
|
==== {api-request-title}
|
|
|
|
`POST _aliases`
|
|
|
|
[[indices-aliases-api-prereqs]]
|
|
==== {api-prereq-title}
|
|
|
|
* If the {es} {security-features} are enabled, you must have the following
|
|
<<privileges-list-indices,index privileges>>:
|
|
|
|
** To use the `add` or `remove` action, you must have the `manage` index
|
|
privilege for the alias and its data streams or indices.
|
|
|
|
** To use the `remove_index` action, you must have the `manage` index privilege
|
|
for the index.
|
|
|
|
[[indices-aliases-api-query-params]]
|
|
==== {api-query-parms-title}
|
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
|
|
|
|
[role="child_attributes"]
|
|
[[indices-aliases-api-request-body]]
|
|
==== {api-request-body-title}
|
|
|
|
`actions`::
|
|
(Required, array of objects) Actions to perform.
|
|
+
|
|
.Properties of `actions` objects
|
|
[%collapsible%open]
|
|
====
|
|
`<action>`::
|
|
(Required, object) The key is the action type. At least one action is required.
|
|
+
|
|
.Valid `<action>` keys
|
|
[%collapsible%open]
|
|
=====
|
|
`add`::
|
|
Adds a data stream or index to an alias. If the alias doesn't exist, the `add`
|
|
action creates it.
|
|
|
|
`remove`::
|
|
Removes a data stream or index from an alias.
|
|
|
|
`remove_index`::
|
|
Deletes an index. You cannot use this action on aliases or data streams.
|
|
=====
|
|
+
|
|
The object body contains options for the alias. Supports an empty object.
|
|
+
|
|
.Properties of `<action>`
|
|
[%collapsible%open]
|
|
=====
|
|
`alias`::
|
|
(Required*, string) Alias for the action. Index alias names support
|
|
<<date-math-index-names,date math>>. If `aliases` is not specified, the `add`
|
|
and `remove` actions require this parameter. For the `remove` action, this
|
|
parameter supports wildcards (`*`). The `remove_index` action doesn't support
|
|
this parameter.
|
|
|
|
`aliases`::
|
|
(Required*, array of strings) Aliases for the action. Index alias names support
|
|
<<date-math-index-names,date math>>. If `alias` is not specified, the `add` and
|
|
`remove` actions require this parameter. For the `remove` action, this parameter
|
|
supports wildcards (`*`). The `remove_index` action doesn't support this
|
|
parameter.
|
|
|
|
// tag::alias-options[]
|
|
`filter`::
|
|
(Optional, <<query-dsl,Query DSL object>> Query used to limit documents the
|
|
alias can access.
|
|
// end::alias-options[]
|
|
+
|
|
Only the `add` action supports this parameter.
|
|
|
|
`index`::
|
|
(Required*, string) Data stream or index for the action. Supports wildcards
|
|
(`*`). If `indices` is not specified, this parameter is required. For the `add`
|
|
and `remove_index` actions, wildcard patterns that match both data streams and
|
|
indices return an error.
|
|
|
|
`indices`::
|
|
(Required*, array of strings) Data streams or indices for the action. Supports
|
|
wildcards (`*`). If `index` is not specified, this parameter is required. For
|
|
the `add` and `remove_index` actions, wildcard patterns that match both data
|
|
streams and indices return an error.
|
|
|
|
// tag::alias-options[]
|
|
`index_routing`::
|
|
(Optional, string) Value used to route indexing operations to a specific shard.
|
|
If specified, this overwrites the `routing` value for indexing operations. Data
|
|
stream aliases don't support this parameter.
|
|
// end::alias-options[]
|
|
+
|
|
Only the `add` action supports this parameter.
|
|
|
|
// tag::alias-options[]
|
|
`is_hidden`::
|
|
(Optional, Boolean) If `true`, the alias is <<hidden,hidden>>. Defaults to
|
|
`false`. All data streams or indices for the alias must have the same
|
|
`is_hidden` value.
|
|
// end::alias-options[]
|
|
+
|
|
Only the `add` action supports this parameter.
|
|
|
|
// tag::alias-options[]
|
|
`is_write_index`::
|
|
(Optional, Boolean) If `true`, sets the <<write-index,write index or data
|
|
stream>> for the alias. Defaults to `false`.
|
|
// end::alias-options[]
|
|
+
|
|
Only the `add` action supports this parameter.
|
|
|
|
`must_exist`::
|
|
(Optional, Boolean)
|
|
If `true`, the alias must exist to perform the action. Defaults to `false`. Only
|
|
the `remove` action supports this parameter.
|
|
|
|
// tag::alias-options[]
|
|
`routing`::
|
|
(Optional, string) Value used to route indexing and search operations to a
|
|
specific shard. Data stream aliases don't support this parameter.
|
|
// end::alias-options[]
|
|
+
|
|
Only the `add` action supports this parameter.
|
|
|
|
// tag::alias-options[]
|
|
`search_routing`::
|
|
(Optional, string) Value used to route search operations to a specific shard. If
|
|
specified, this overwrites the `routing` value for search operations. Data
|
|
stream aliases don't support this parameter.
|
|
// end::alias-options[]
|
|
+
|
|
Only the `add` action supports this parameter.
|
|
=====
|
|
====
|