Rolling over an index
When you're using a system that manages logs, it is very common to use rolling files for your log entries. By doing so, you can have indices that are similar to rolling files.
You can define some conditions that must be checked and leave it to Elasticsearch to roll new indices automatically and refer the use of an alias to a virtual index.
Getting ready
You will need an up-and-running Elasticsearch installation, as we described in 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 and better character escaping for Elasticsearch.
How to do it…
To enable a rolling index, we need an index with an alias that points to it alone. For example, to set a log rolling index, we would follow these...