Cleaning the cache
During its execution, Elasticsearch caches data to speed up searching, such as cache results, items and filter results.
To free up memory, it's necessary to clean cache API.
Getting ready
You need an up-and-running Elasticsearch installation as we described in the Downloading and installing Elasticsearch recipe in Chapter 2, Downloading and Setup.
To execute curl
via the command-line, you need to install curl
for your operating system.
How to do it...
For cleaning the cache, we will perform the following steps:
We call the
cleancache
API on an index as follows:curl -XPOST 'http://localhost:9200/test-index/_cache/clear'
The result returned by Elasticsearch, if everything is okay, should be as follows:
{ "_shards" : { "total" : 10, "successful" : 5, "failed" : 0 } }
How it works...
The cache clean API frees the memory used to cache values in Elasticsearch.
Generally, it's not a good idea to clean...