Skip to content

Commit 8f77726

Browse files
authored
Update docs for Open/Close API (#43809)
Relates #43530
1 parent 525f9c0 commit 8f77726

File tree

1 file changed

+55
-9
lines changed

1 file changed

+55
-9
lines changed

docs/reference/indices/open-close.asciidoc

+55-9
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,68 @@
22
== Open / Close Index API
33

44
The open and close index APIs allow to close an index, and later on
5-
opening it. A closed index has almost no overhead on the cluster (except
6-
for maintaining its metadata), and is blocked for read/write operations.
7-
A closed index can be opened which will then go through the normal
8-
recovery process.
5+
opening it.
96

10-
The REST endpoint is `/{index}/_close` and `/{index}/_open`. For
11-
example:
7+
A closed index is blocked for read/write operations and does not allow
8+
all operations that opened indices allow. It is not possible to index
9+
documents or to search for documents in a closed index. This allows
10+
closed indices to not have to maintain internal data structures for
11+
indexing or searching documents, resulting in a smaller overhead on
12+
the cluster.
13+
14+
When opening or closing an index, the master is responsible for
15+
restarting the index shards to reflect the new state of the index.
16+
The shards will then go through the normal recovery process. The
17+
data of opened/closed indices is automatically replicated by the
18+
cluster to ensure that enough shard copies are safely kept around
19+
at all times.
20+
21+
The REST endpoint is `/{index}/_close` and `/{index}/_open`.
22+
23+
The following example shows how to close an index:
1224

1325
[source,js]
1426
--------------------------------------------------
1527
POST /my_index/_close
28+
--------------------------------------------------
29+
// CONSOLE
30+
// TEST[s/^/PUT my_index\n/]
31+
32+
This will return the following response:
33+
34+
[source,js]
35+
--------------------------------------------------
36+
{
37+
"acknowledged" : true,
38+
"shards_acknowledged" : true,
39+
"indices" : {
40+
"my_index" : {
41+
"closed" : true
42+
}
43+
}
44+
}
45+
--------------------------------------------------
46+
// TESTRESPONSE
47+
48+
A closed index can be reopened like this:
1649

50+
[source,js]
51+
--------------------------------------------------
1752
POST /my_index/_open
1853
--------------------------------------------------
1954
// CONSOLE
20-
// TEST[s/^/PUT my_index\n/]
55+
// TEST[s/^/PUT my_index\nPOST my_index\/_close\n/]
56+
57+
which will yield the following response:
58+
59+
[source,js]
60+
--------------------------------------------------
61+
{
62+
"acknowledged" : true,
63+
"shards_acknowledged" : true
64+
}
65+
--------------------------------------------------
66+
// TESTRESPONSE
2167

2268
It is possible to open and close multiple indices. An error will be thrown
2369
if the request explicitly refers to a missing index. This behaviour can be
@@ -36,6 +82,6 @@ API by setting `cluster.indices.close.enable` to `false`. The default is `true`.
3682
[float]
3783
=== Wait For Active Shards
3884

39-
Because opening an index allocates its shards, the
85+
Because opening or closing an index allocates its shards, the
4086
<<create-index-wait-for-active-shards,`wait_for_active_shards`>> setting on
41-
index creation applies to the index opening action as well.
87+
index creation applies to the `_open` and `_close` index actions as well.

0 commit comments

Comments
 (0)