Opening/closing an index
If you want to keep your data but save resources (memory/CPU), a good alternative to deleting indexes is to close them.
Elasticsearch allows you to open/close an index putting it into online/offline mode.
Getting ready
You need an up-and-running Elasticsearch installation, as used in the Downloading and installing Elasticsearch recipe in Chapter 2, Downloading and Setup.
To execute curl
via the command line, you need to install curl
for your operative system.
To correctly execute the following commands, the index created in the Creating an index recipe is required.
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 using: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, type the following command:
curl -XPOST...