⚠️ This lesson is retired and might contain outdated information.

Close and open an Elasticsearch index

Will Button
InstructorWill Button
Share this video with your friends

Social Share Links

Send Tweet

Closing and opening indices on Elasticsearch allow you to free up resources in your cluster when they aren’t needed, preventing you from scaling or growing your cluster to support unused indices. In this lesson, you will see how easy it is to do both and learn to do so on your own indices.

[00:01] We can also close an index using the close API endpoint. That comes back as acknowledged equal to true. Now whenever we look at all of our indices, using the CAT interface, we can see the Simpsons index is still there, but now it's in a closed state, as well as it doesn't have a health status, because it's closed. When an index is closed, it consumes almost no resources on the Elasticsearch cluster.

[00:31] One useful application for closing indices is with logs. If you send all of your server logs to Elasticsearch, it can occupy quite a bit of resources, over time, that aren't necessary. You can have a rule where log indices remain open for seven days and are closed after that. This will improve the performance of your cluster, as logs from years ago aren't consuming resources.

[00:54] If they're even needed, they can be accessed by simply opening the correct index. The way we would do that would be another post operation to the Simpsons index, and this time call the open endpoint, send that. Now if we take a look at all of our indices again, the Simpsons index is back open.