2013-08-28 19:24:34 -04:00
|
|
|
[[indices-open-close]]
|
2019-08-27 11:17:51 -04:00
|
|
|
=== Open index API
|
|
|
|
++++
|
|
|
|
<titleabbrev>Open index</titleabbrev>
|
|
|
|
++++
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2020-07-01 11:22:45 -04:00
|
|
|
Opens a closed index. For data streams, the API
|
|
|
|
opens any closed backing indices.
|
2019-08-27 11:17:51 -04:00
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
[source,console]
|
2019-08-27 11:17:51 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
POST /twitter/_open
|
|
|
|
--------------------------------------------------
|
|
|
|
// TEST[setup:twitter]
|
|
|
|
// TEST[s/^/POST \/twitter\/_close\n/]
|
|
|
|
|
|
|
|
|
|
|
|
[[open-index-api-request]]
|
|
|
|
==== {api-request-title}
|
|
|
|
|
2020-07-01 11:22:45 -04:00
|
|
|
`POST /<target>/_open`
|
2019-08-27 11:17:51 -04:00
|
|
|
|
|
|
|
|
|
|
|
[[open-index-api-desc]]
|
|
|
|
==== {api-description-title}
|
|
|
|
|
2020-07-01 11:22:45 -04:00
|
|
|
You can use the open index API to re-open closed indices. If the request targets
|
|
|
|
a data stream, the request re-opens any of the stream's closed backing indices.
|
2019-08-27 11:17:51 -04:00
|
|
|
|
2019-08-27 12:31:53 -04:00
|
|
|
// tag::closed-index[]
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-07-01 09:19:44 -04:00
|
|
|
A closed index is blocked for read/write operations and does not allow
|
|
|
|
all operations that opened indices allow. It is not possible to index
|
|
|
|
documents or to search for documents in a closed index. This allows
|
|
|
|
closed indices to not have to maintain internal data structures for
|
|
|
|
indexing or searching documents, resulting in a smaller overhead on
|
|
|
|
the cluster.
|
|
|
|
|
|
|
|
When opening or closing an index, the master is responsible for
|
|
|
|
restarting the index shards to reflect the new state of the index.
|
|
|
|
The shards will then go through the normal recovery process. The
|
|
|
|
data of opened/closed indices is automatically replicated by the
|
|
|
|
cluster to ensure that enough shard copies are safely kept around
|
|
|
|
at all times.
|
|
|
|
|
2019-08-27 11:17:51 -04:00
|
|
|
You can open and close multiple indices. An error is thrown
|
|
|
|
if the request explicitly refers to a missing index. This behaviour can be
|
|
|
|
disabled using the `ignore_unavailable=true` parameter.
|
2019-07-01 09:19:44 -04:00
|
|
|
|
2019-08-27 11:17:51 -04:00
|
|
|
All indices can be opened or closed at once using `_all` as the index name
|
|
|
|
or specifying patterns that identify them all (e.g. `*`).
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-08-27 11:17:51 -04:00
|
|
|
Identifying indices via wildcards or `_all` can be disabled by setting the
|
|
|
|
`action.destructive_requires_name` flag in the config file to `true`.
|
|
|
|
This setting can also be changed via the cluster update settings api.
|
2019-07-01 09:19:44 -04:00
|
|
|
|
2020-06-17 11:39:58 -04:00
|
|
|
Closed indices consume a significant amount of disk-space which can cause
|
|
|
|
problems in managed environments. Closing indices can be disabled via the cluster settings
|
2019-08-27 11:17:51 -04:00
|
|
|
API by setting `cluster.indices.close.enable` to `false`. The default is `true`.
|
2019-07-01 09:19:44 -04:00
|
|
|
|
2020-06-17 11:39:58 -04:00
|
|
|
The current write index on a data stream cannot be closed. In order to close
|
|
|
|
the current write index, the data stream must first be
|
|
|
|
<<rollover-data-stream-ex,rolled over>> so that a new write index is created
|
|
|
|
and then the previous write index can be closed.
|
|
|
|
|
2020-06-30 08:06:52 -04:00
|
|
|
// end::closed-index[]
|
|
|
|
|
|
|
|
[[open-index-api-wait-for-active-shards]]
|
2019-08-27 11:17:51 -04:00
|
|
|
===== Wait For active shards
|
2019-07-01 09:19:44 -04:00
|
|
|
|
2020-06-30 08:06:52 -04:00
|
|
|
// tag::wait-for-active-shards[]
|
|
|
|
|
2019-08-27 11:17:51 -04:00
|
|
|
Because opening or closing an index allocates its shards, the
|
|
|
|
<<create-index-wait-for-active-shards,`wait_for_active_shards`>> setting on
|
|
|
|
index creation applies to the `_open` and `_close` index actions as well.
|
|
|
|
|
2020-06-30 08:06:52 -04:00
|
|
|
// end::wait-for-active-shards[]
|
|
|
|
|
|
|
|
|
2019-08-27 11:17:51 -04:00
|
|
|
|
|
|
|
|
|
|
|
[[open-index-api-path-params]]
|
|
|
|
==== {api-path-parms-title}
|
|
|
|
|
2020-07-01 11:22:45 -04:00
|
|
|
`<target>`::
|
|
|
|
(Optional, string)
|
|
|
|
Comma-separated list or wildcard (`*`) expression of data streams, indices, and
|
|
|
|
index aliases used to limit the request.
|
2019-08-27 11:17:51 -04:00
|
|
|
+
|
2020-07-01 11:22:45 -04:00
|
|
|
To target all data streams and indices, use `_all` or `*`.
|
|
|
|
+
|
|
|
|
To disallow use of `_all` or wildcard expressions,
|
2019-08-27 11:17:51 -04:00
|
|
|
change the `action.destructive_requires_name` cluster setting to `true`.
|
|
|
|
You can update this setting in the `elasticsearch.yml` file
|
|
|
|
or using the <<cluster-update-settings,cluster update settings>> API.
|
|
|
|
|
|
|
|
|
|
|
|
[[open-index-api-query-params]]
|
|
|
|
==== {api-query-parms-title}
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
|
2020-02-24 05:57:32 -05:00
|
|
|
+
|
|
|
|
Defaults to `true`.
|
2019-08-27 11:17:51 -04:00
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
|
2019-08-27 11:17:51 -04:00
|
|
|
+
|
|
|
|
Defaults to `closed`.
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
|
2019-08-27 11:17:51 -04:00
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=wait_for_active_shards]
|
2019-08-27 11:17:51 -04:00
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
|
2019-08-27 11:17:51 -04:00
|
|
|
|
|
|
|
|
|
|
|
[[open-index-api-example]]
|
|
|
|
==== {api-examples-title}
|
|
|
|
|
2020-07-01 11:22:45 -04:00
|
|
|
The following request re-opens a closed index named `my_index`.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
[source,console]
|
2019-07-01 09:19:44 -04:00
|
|
|
--------------------------------------------------
|
2016-09-01 13:05:22 -04:00
|
|
|
POST /my_index/_open
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
2019-07-01 09:19:44 -04:00
|
|
|
// TEST[s/^/PUT my_index\nPOST my_index\/_close\n/]
|
|
|
|
|
2019-08-27 11:17:51 -04:00
|
|
|
The API returns the following response:
|
2019-07-01 09:19:44 -04:00
|
|
|
|
2019-09-06 09:22:08 -04:00
|
|
|
[source,console-result]
|
2019-07-01 09:19:44 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
{
|
2020-07-21 15:49:58 -04:00
|
|
|
"acknowledged" : true,
|
|
|
|
"shards_acknowledged" : true
|
2019-07-01 09:19:44 -04:00
|
|
|
}
|
|
|
|
--------------------------------------------------
|