2
2
== Open / Close Index API
3
3
4
4
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.
9
6
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:
12
24
13
25
[source,js]
14
26
--------------------------------------------------
15
27
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:
16
49
50
+ [source,js]
51
+ --------------------------------------------------
17
52
POST /my_index/_open
18
53
--------------------------------------------------
19
54
// 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
21
67
22
68
It is possible to open and close multiple indices. An error will be thrown
23
69
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`.
36
82
[float]
37
83
=== Wait For Active Shards
38
84
39
- Because opening an index allocates its shards, the
85
+ Because opening or closing an index allocates its shards, the
40
86
<<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