Open / Close Index APIedit

The open and close index APIs allow to close an index, and later on opening it.

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.

The REST endpoint is /{index}/_close and /{index}/_open.

The following example shows how to close an index:

POST /my_index/_close?wait_for_active_shards=1

This will return the following response:

{
    "acknowledged" : true,
    "shards_acknowledged" : true
}

A closed index can be reopened like this:

POST /my_index/_open

which will yield the following response:

{
    "acknowledged" : true,
    "shards_acknowledged" : true
}

It is possible to open and close multiple indices. An error will be thrown if the request explicitly refers to a missing index. This behaviour can be disabled using the ignore_unavailable=true parameter.

All indices can be opened or closed at once using _all as the index name or specifying patterns that identify them all (e.g. *).

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.

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.

Wait For Active Shardsedit

Because opening or closing an index allocates its shards, the wait_for_active_shards setting on index creation applies to the _open and _close index actions as well.