123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- [[indices-open-close]]
- === Open index API
- ++++
- <titleabbrev>Open index</titleabbrev>
- ++++
- Opens a closed index. For data streams, the API
- opens any closed backing indices.
- [source,console]
- --------------------------------------------------
- POST /my-index-000001/_open
- --------------------------------------------------
- // TEST[setup:my_index]
- // TEST[s/^/POST \/my-index-000001\/_close\n/]
- [[open-index-api-request]]
- ==== {api-request-title}
- `POST /<target>/_open`
- [[open-index-api-prereqs]]
- ==== {api-prereq-title}
- * If the {es} {security-features} are enabled, you must have the `manage`
- <<privileges-list-indices,index privilege>> for the target data stream, index,
- or index alias.
- [[open-index-api-desc]]
- ==== {api-description-title}
- 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.
- // tag::closed-index[]
- 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.
- 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.
- By default, you must explicitly name the indices you are opening or closing.
- To open or close indices with `_all`, `*`, or other wildcard
- expressions, change the `action.destructive_requires_name` setting to `false`.
- This setting can also be changed via the cluster update settings api.
- 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
- API by setting `cluster.indices.close.enable` to `false`. The default is `true`.
- // end::closed-index[]
- [[open-index-api-wait-for-active-shards]]
- ===== Wait for active shards
- // tag::wait-for-active-shards[]
- 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.
- // end::wait-for-active-shards[]
- [[open-index-api-path-params]]
- ==== {api-path-parms-title}
- `<target>`::
- (Optional, string)
- Comma-separated list of data streams, indices, and index aliases used to limit
- the request. Wildcard (`*`) expressions are supported.
- +
- +
- By default, you must explicitly name the indices you using to limit the request.
- To limit a request using `_all`, `*`, or other wildcard
- expressions, change the `action.destructive_requires_name` setting to `false`.
- 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}
- include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
- +
- Defaults to `true`.
- include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
- +
- Defaults to `closed`.
- include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
- include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=wait_for_active_shards]
- include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
- [[open-index-api-example]]
- ==== {api-examples-title}
- The following request re-opens a closed index named `my-index-000001`.
- [source,console]
- --------------------------------------------------
- POST /my-index-000001/_open
- --------------------------------------------------
- // TEST[s/^/PUT my-index-000001\nPOST my-index-000001\/_close\n/]
- The API returns the following response:
- [source,console-result]
- --------------------------------------------------
- {
- "acknowledged" : true,
- "shards_acknowledged" : true
- }
- --------------------------------------------------
|