diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverAction.java b/core/src/main/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverAction.java index d88cfe35f8f..82c54f8a1bd 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverAction.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverAction.java @@ -47,6 +47,7 @@ import org.elasticsearch.index.shard.DocsStats; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.util.Locale; import java.util.Set; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -171,7 +172,7 @@ public class TransportRolloverAction extends TransportMasterNodeAction +PUT /logs-000001 <1> { "aliases": { "logs_write": {} @@ -28,18 +28,18 @@ POST logs_write/_rollover <2> } -------------------------------------------------- // CONSOLE -<1> Creates an index called `logs-0001` with the alias `logs_write`. +<1> Creates an index called `logs-0000001` with the alias `logs_write`. <2> If the index pointed to by `logs_write` was created 7 or more days ago, or contains 1,000 or more documents, then the `logs-0002` index is created - and the `logs_write` alias is updated to point to `logs-0002`. + and the `logs_write` alias is updated to point to `logs-000002`. The above request might return the following response: [source,js] -------------------------------------------------- { - "old_index": "logs-0001", - "new_index": "logs-0002", + "old_index": "logs-000001", + "new_index": "logs-000002", "rolled_over": true, <1> "dry_run": false, <2> "conditions": { <3> @@ -56,8 +56,9 @@ The above request might return the following response: === Naming the new index If the name of the existing index ends with `-` and a number -- e.g. -`logs-0001` -- then the name of the new index will follow the same pattern, -just incrementing the number (`logs-0002`). +`logs-000001` -- then the name of the new index will follow the same pattern, +incrementing the number (`logs-000002`). The number is zero-padded with a length +of 6, regardless of the old index name. If the old name doesn't match this pattern then you must specify the name for the new index as follows: @@ -80,7 +81,7 @@ override any values set in matching index templates. For example, the following [source,js] -------------------------------------------------- -PUT /logs-0001 +PUT /logs-000001 { "aliases": { "logs_write": {} @@ -108,7 +109,7 @@ checked without performing the actual rollover: [source,js] -------------------------------------------------- -PUT /logs-0001 +PUT /logs-000001 { "aliases": { "logs_write": {} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/10_basic.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/10_basic.yaml index 199d4561d09..8c962407b30 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/10_basic.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.rollover/10_basic.yaml @@ -39,7 +39,7 @@ max_docs: 1 - match: { old_index: logs-1 } - - match: { new_index: logs-2 } + - match: { new_index: logs-000002 } - match: { rolled_over: true } - match: { dry_run: false } - match: { conditions: { "[max_docs: 1]": true } } @@ -47,14 +47,14 @@ # ensure new index is created - do: indices.exists: - index: logs-2 + index: logs-000002 - is_true: '' # index into new index - do: index: - index: logs-2 + index: logs-000002 type: test id: "2" body: { "foo": "hello world" } @@ -69,5 +69,5 @@ type: test - match: { hits.total: 1 } - - match: { hits.hits.0._index: "logs-2"} + - match: { hits.hits.0._index: "logs-000002"}