liveBook · Manning

_rollover API

As explained in Elasticsearch in Action, Second Edition

The _rollover API is an Elasticsearch API that creates a successor index and repoints an alias to it according to rollover rules.

The _rollover API supports time-based or continuously growing data, such as application logs or car documents. It creates a successor index and continues access through an alias. section 6.8.3

Listing 6.45 Creating an alias for an existing index
POST _aliases                           #1
{
  "actions": [                          #2
    {
      "add": {                          #3
        "index": "cars_2021-000001",    #4
        "alias": "latest_cars_a",       #5
        "is_write_index": true          #6
      }
    }
  ]
}

Create an alias for the current index before rolling it over. The alias must have a writable backing index, marked with is_write_index: true. section 6.8.3

Roll over a car index

POST latest_cars_a/_rollover A successful response identifies the old and new indexes, such as latest_cars-000001 and latest_cars-000002. Index names need a positive numeric suffix; Elasticsearch increments it and pads it with zeros. The API also supports index or data stream aliases. section 6.8.3

How Elasticsearch in Action, Second Edition covers it

How deep it goes
Explains alias preparation, writable-index requirements, endpoint usage, responses, and numeric suffix incrementing.
Examples
Uses application logs, car indexes, alias creation, rollover requests, and old/new index responses.
What it assumes
Assumes an existing index, then teaches how to create its writable alias before rollover.
What you can do after
Operate/configure an alias for rollover and invoke the _rollover endpoint to create a successor index.
How it connects
Connects aliases, indexes, data streams, write indexes, and index naming.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Elasticsearch in Action, Second Edition. The section links point to the parts of the book it draws on.