Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson

Already subscribed? Sign In

Autoplay

    Close and open an Elasticsearch index

    Will ButtonWill Button

    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.

    elasticsearchelasticsearch
    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Transcript

    Transcript

    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.

    Discuss

    Discuss