Roll over to a new index
- POST /{alias}/_rollover/{new_index}
- POST /{alias}/_rollover
TIP: We recommend using the index lifecycle rollover action to automate rollovers. However, Serverless does not support Index Lifecycle Management (ILM), so don't use this approach in the Serverless context.
The rollover API creates a new index for a data stream or index alias. The API behavior depends on the rollover target.
Roll over a data stream
If you roll over a data stream, the API creates a new write index for the stream. The stream's previous write index becomes a regular backing index. A rollover also increments the data stream's generation.
Roll over an index alias with a write index
TIP: Prior to Elasticsearch 7.9, you'd typically use an index alias with a write index to manage time series data. Data streams replace this functionality, require less maintenance, and automatically integrate with data tiers.
If an index alias points to multiple indices, one of the indices must be a write index.
The rollover API creates a new write index for the alias with is_write_index set to true.
The API also sets is_write_index to false for the previous write index.
Roll over an index alias with one index
If you roll over an index alias that points to only one index, the API creates a new index for the alias and removes the original index from the alias.
NOTE: A rollover creates a new index and is subject to the wait_for_active_shards setting.
Increment index names for an alias
When you roll over an index alias, you can specify a name for the new index.
If you don't specify a name and the current index ends with - and a number, such as my-index-000001 or my-index-3, the new index name increments that number.
For example, if you roll over an alias with a current index of my-index-000001, the rollover creates a new index named my-index-000002.
This number is always six characters and zero-padded, regardless of the previous index's name.
If you use an index alias for time series data, you can use date math in the index name to track the rollover date.
For example, you can create an alias that points to an index named <my-index-{now/d}-000001>.
If you create the index on May 6, 2099, the index's name is my-index-2099.05.06-000001.
If you roll over the alias on May 7, 2099, the new index's name is my-index-2099.05.07-000002.
- Index privileges:
manage
Query Parameters
-
dry_runboolean · default: false If
true, checks whether the current index satisfies the specified conditions but does not perform a rollover.-
master_timeoutstring Duration · default: 30s Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error.
-
timeoutstring Duration · default: 30s Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.
-
lazyboolean · default: false If set to true, the rollover action will only mark a data stream to signal that it needs to be rolled over at the next write. Only allowed on data streams.
Request
-
aliasesmap string to Alias -
Aliases for the target index. Data streams do not support this parameter.
-
<string>Alias -
filterQueryContainer -
Query used to limit documents the alias can access.
-
index_routingstring -
Value used to route indexing operations to a specific shard. If specified, this overwrites the
routingvalue for indexing operations. -
If
true, the alias is hidden. All indices for the alias must have the sameis_hiddenvalue. -
is_write_indexboolean · default: false -
If
true, the index is the write index for the alias. -
routingstring -
Value used to route indexing and search operations to a specific shard.
-
search_routingstring -
Value used to route search operations to a specific shard. If specified, this overwrites the
routingvalue for search operations. -
conditionsRolloverConditions -
Conditions for the rollover. If specified, Elasticsearch only performs the rollover if the current index satisfies these conditions. If this parameter is not specified, Elasticsearch performs the rollover unconditionally. If conditions are specified, at least one of them must be a
max_*condition. The index will rollover if anymax_*condition is satisfied and allmin_*conditions are satisfied. -
min_agestring Duration -
max_agestring Duration -
max_age_millisDurationValueUnitMillis -
min_docsnumber -
max_docsnumber -
max_sizenumber | string ByteSizedeprecated -
The
max_sizecondition has been deprecated in 9.3.0 andmax_primary_shard_sizeshould be used instead -
max_size_bytesnumber -
min_sizenumber | string ByteSize -
min_size_bytesnumber -
max_primary_shard_sizenumber | string ByteSize -
max_primary_shard_size_bytesnumber -
min_primary_shard_sizenumber | string ByteSize -
min_primary_shard_size_bytesnumber -
max_primary_shard_docsnumber -
min_primary_shard_docsnumber -
mappingsTypeMapping -
Mapping for fields in the index. If specified, this mapping can include field names, field data types, and mapping paramaters.
-
all_fieldAllField -
analyzerstringrequired -
enabledbooleanrequired -
omit_normsbooleanrequired -
search_analyzerstringrequired -
similaritystringrequired -
storebooleanrequired -
store_term_vector_offsetsbooleanrequired -
store_term_vector_payloadsbooleanrequired -
store_term_vector_positionsbooleanrequired -
store_term_vectorsbooleanrequired -
date_detectionboolean -
dynamicDynamicMapping -
Values:
strictruntimetruefalse -
dynamic_date_formatsstring -
dynamic_templatesstring to DynamicTemplate -
_field_namesFieldNamesField -
enabledbooleanrequired -
index_fieldIndexField -
enabledbooleanrequired -
_metaMetadata -
numeric_detectionboolean -
propertiesmap string to Property -
_sourceSourceField -
runtimemap string to RuntimeField -
<string>RuntimeField -
fieldsmap string to CompositeSubField -
For type
composite -
<string>CompositeSubField -
typeRuntimeFieldTyperequired -
Values:
booleancompositedatedoublegeo_pointgeo_shapeipkeywordlonglookup -
formatstring -
A custom format for
datetype runtime fields. -
input_fieldstring Field -
For type
lookup -
target_fieldstring Field -
For type
lookup -
target_indexstring IndexName -
For type
lookup -
scriptstring Script -
Painless script executed at query time.
-
on_script_errorOnScriptError -
Values:
failcontinue -
typeRuntimeFieldTyperequired -
Field type, which can be:
boolean,composite,date,double,geo_point,ip,keyword,long, orlookup. -
Values:
booleancompositedatedoublegeo_pointgeo_shapeipkeywordlonglookup -
enabledboolean -
subobjectsSubobjects -
Values:
truefalse -
_data_stream_timestampDataStreamTimestamp -
enabledbooleanrequired -
settingsmap string to object -
Configuration options for the index. Data streams do not support this parameter.
Response
-
acknowledgedbooleanrequired -
conditionsmap string to booleanrequired -
dry_runbooleanrequired -
new_indexstringrequired -
old_indexstringrequired -
rolled_overbooleanrequired -
shards_acknowledgedbooleanrequired