|
| 1 | +[role="xpack"] |
| 2 | +[[indices-migrate-to-data-stream]] |
| 3 | +=== Migrate to data stream API |
| 4 | +++++ |
| 5 | +<titleabbrev>Migrate to data stream</titleabbrev> |
| 6 | +++++ |
| 7 | + |
| 8 | +Converts an <<indices-aliases,index alias>> to a <<data-streams,data stream>>. |
| 9 | + |
| 10 | +Data streams require a matching <<indices-templates,index template>>. |
| 11 | +See <<set-up-a-data-stream>>. |
| 12 | + |
| 13 | +//// |
| 14 | +[source,console] |
| 15 | +---- |
| 16 | +POST idx1/_doc/ |
| 17 | +{ |
| 18 | + "message" : "testing", |
| 19 | + "@timestamp" : "2020-01-01" |
| 20 | +} |
| 21 | +
|
| 22 | +POST idx2/_doc/ |
| 23 | +{ |
| 24 | + "message" : "testing2", |
| 25 | + "@timestamp" : "2020-01-01" |
| 26 | +} |
| 27 | +
|
| 28 | +POST /_aliases |
| 29 | +{ |
| 30 | + "actions": [ |
| 31 | + { |
| 32 | + "add": { |
| 33 | + "index": "idx1", |
| 34 | + "alias": "my-logs", |
| 35 | + "is_write_index": true |
| 36 | + } |
| 37 | + }, |
| 38 | + { |
| 39 | + "add": { |
| 40 | + "index": "idx2", |
| 41 | + "alias": "my-logs" |
| 42 | + } |
| 43 | + } |
| 44 | + ] |
| 45 | +} |
| 46 | +
|
| 47 | +PUT /_index_template/template |
| 48 | +{ |
| 49 | + "index_patterns": ["my-logs*"], |
| 50 | + "data_stream": { } |
| 51 | +} |
| 52 | +---- |
| 53 | +//// |
| 54 | + |
| 55 | +[source,console] |
| 56 | +---- |
| 57 | +POST /_data_stream/_migrate/my-logs |
| 58 | +---- |
| 59 | +// TEST[continued] |
| 60 | + |
| 61 | +//// |
| 62 | +[source,console] |
| 63 | +----------------------------------- |
| 64 | +DELETE /_data_stream/my-logs |
| 65 | +DELETE /_index_template/template |
| 66 | +----------------------------------- |
| 67 | +// TEST[continued] |
| 68 | +//// |
| 69 | + |
| 70 | +[[indices-migrate-to-data-stream-request]] |
| 71 | +==== {api-request-title} |
| 72 | + |
| 73 | +`POST /_data_stream/_migrate/<alias>` |
| 74 | + |
| 75 | +[[indices-migrate-to-data-stream-api-path-params]] |
| 76 | +==== {api-path-parms-title} |
| 77 | + |
| 78 | +`<alias>`:: |
| 79 | ++ |
| 80 | +-- |
| 81 | +(Required, string) |
| 82 | +Name of the index alias to convert to a data stream. The alias must meet the |
| 83 | +following criteria: |
| 84 | + |
| 85 | +- The alias must have a <<aliases-write-index,write index>>. |
| 86 | +- All indices for the alias have a `@timestamp` field mapping of a `date` or `date_nanos` field type. |
| 87 | +- The alias must not have any <<filtered,filters>>. |
| 88 | +- The alias must not use <<aliases-routing,custom routing>>. |
| 89 | + |
| 90 | +If successful, the request removes the alias and creates a data stream with the |
| 91 | +same name. The alias's indices become hidden backing indices for the stream. The |
| 92 | +alias's write index becomes the stream's write index. |
| 93 | +-- |
0 commit comments