Opening/closing an index
If you want to keep your data but save resources (memory/CPU), a good alternative to deleting an Index is to close it.
ElasticSearch allows you to open or close an index to put it in online/offline mode.
Getting ready
You will need a working ElasticSearch cluster and the index created in the Creating an index recipe in this chapter.
How to do it...
For opening/closing an index, we will perform the following steps:
From the command line, we can execute a POST call to close an index:
curl -XPOST http://127.0.0.1:9200/myindex/_close
If the call is successful, the result returned by ElasticSearch should be:
{,"acknowledged":true}
To open an index from the command line, enter:
curl -XPOST http://127.0.0.1:9200/myindex/_open
If the call is successful, the result returned by ElasticSearch should be:
{"acknowledged":true}
How it works...
When an index is closed, there is no overhead on the cluster (except for the metadata state); the index shards are turned off and don't use file descriptors...