Book Image

ElasticSearch Cookbook

By : Alberto Paro
Book Image

ElasticSearch Cookbook

By: Alberto Paro

Overview of this book

Table of Contents (20 chapters)
ElasticSearch Cookbook Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

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 call is successful, the result returned by ElasticSearch should be:

    {"acknowledged":true}

How it works...

When an index is closed, there is no overhead on the cluster (except for the metadata state); the index shards are turned off and don't use file descriptors...