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 them.
ElasticSearch allows to open/close an index for putting it in the online/offline mode.
Getting ready
You need a working ElasticSearch cluster and the index created in the Creating an index recipe.
How to do it...
For opening/closing an index, we need to perform the following steps:
From command line, we can execute a POST call to close an index as follows:
curl -XPOST http://127.0.0.1:9200/myindex/_close
If the call is successfully made, the result returned by ElasticSearch should be as follows:
{"ok":true,"acknowledged":true}
To open an index from command line use the following command:
curl -XPOST http://127.0.0.1:9200/myindex/_open
If the call is successfully made, the result returned by ElasticSearch should be as follows:
{"ok":true,"acknowledged":true}
How it works...
When an index is closed, there is no overhead on the cluster (except for metadata state...