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