elasticsearch/docs/reference/indices/open-close.asciidoc
Liam Thompson 33a71e3289
[DOCS] Refactor book-scoped variables in docs/reference/index.asciidoc (#107413)
* Remove `es-test-dir` book-scoped variable

* Remove `plugins-examples-dir` book-scoped variable

* Remove `:dependencies-dir:` and `:xes-repo-dir:` book-scoped variables

- In `index.asciidoc`, two variables (`:dependencies-dir:` and `:xes-repo-dir:`) were removed.
- In `sql/index.asciidoc`, the `:sql-tests:` path was updated to fuller path
- In `esql/index.asciidoc`, the `:esql-tests:` path was updated idem

* Replace `es-repo-dir` with `es-ref-dir`

* Move `:include-xpack: true` to few files that use it, remove from index.asciidoc
2024-04-17 14:37:07 +02:00

133 lines
4.3 KiB
Text

[[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 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 aliases used to limit
the request. Supports wildcards (`*`).
+
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-ref-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
+
Defaults to `true`.
include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
+
Defaults to `closed`.
include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=wait_for_active_shards]
include::{es-ref-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
}
--------------------------------------------------