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

Flushing an index


ElasticSearch, for performance reasons, stores some data in memory and on a transaction log. If we want to free memory, empty the transaction log, and be sure that our data is safely written on disk, we need to flush an index.

ElasticSearch automatically provides a periodic disk flush, but forcing a flush can be useful, for example:

  • When we have to shutdown a node to prevent stale data

  • To have all the data in a safe state (for example, after a big indexing operation to have all the data flushed and refreshed)

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...

The HTTP method used for the URL operations is POST.

The URL format for flushing an index is:

http://<server>/<index_name(s)>/_flush[?refresh=True]

The URL format for flushing all the indices in a Cluster is:

http://<server>/_flush[?refresh=True]

To flush an index, we will perform the following steps:

  1. If we consider...