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:

  1. From the command line, we can execute a POST call to close an index:
    curl -XPOST http://127.0.0.1:9200/myindex/_close
    
  2. If the call is successful, the result returned by ElasticSearch should be:
    {,"acknowledged":true}
  3. To open an index from the command line, enter:
    curl -XPOST http://127.0.0.1:9200/myindex/_open
    
  4. If the ...

Get ElasticSearch Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.