Shrinking an index
The latest version of Elasticsearch provides us with a new way to optimize an index. By using the shrink API, it's possible to reduce the number of shards in an index.
This feature targets several common scenarios:
- A wrong number of shards will be provided during the initial design sizing. Often, sizing the shards without knowing the correct data or text distribution tends to oversize the number of shards.
- You should reduce the number of shards to reduce memory and resource usage.
- You should reduce the number of shards to speed up searching.
Getting ready
You will need an up-and-running Elasticsearch installation, as we described in the Downloading and installing Elasticsearch recipe of Chapter 1, Getting Started.
To execute the commands in this recipe, you can use any HTTP client, such as curl (https://curl.haxx.se/), Postman (https://www.getpostman.com/), or others. I suggest using the Kibana console as it provides code completion...