Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOCS] Data stream migration API #65017

Merged
merged 8 commits into from
Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/reference/data-streams/data-stream-apis.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The following APIs are available for managing <<data-streams,data streams>>:
* <<indices-create-data-stream>>
* <<indices-delete-data-stream>>
* <<indices-get-data-stream>>
* <<indices-migrate-to-data-stream>>
* <<data-stream-stats-api>>

For concepts and tutorials, see <<data-streams>>.
Expand All @@ -17,4 +18,6 @@ include::{es-repo-dir}/indices/delete-data-stream.asciidoc[]

include::{es-repo-dir}/indices/get-data-stream.asciidoc[]

include::{es-repo-dir}/indices/data-stream-stats.asciidoc[]
include::{es-repo-dir}/indices/migrate-to-data-stream.asciidoc[]

include::{es-repo-dir}/indices/data-stream-stats.asciidoc[]
93 changes: 93 additions & 0 deletions docs/reference/indices/migrate-to-data-stream.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
[role="xpack"]
[[indices-migrate-to-data-stream]]
=== Migrate to data stream API
++++
<titleabbrev>Migrate to data stream</titleabbrev>
++++

Converts an <<indices-aliases,index alias>> to a <<data-streams,data stream>>.

Data streams require a matching <<indices-templates,index template>>.
See <<set-up-a-data-stream>>.

////
[source,console]
----
POST idx1/_doc/
{
"message" : "testing",
"@timestamp" : "2020-01-01"
}

POST idx2/_doc/
{
"message" : "testing2",
"@timestamp" : "2020-01-01"
}

POST /_aliases
{
"actions": [
{
"add": {
"index": "idx1",
"alias": "my-logs",
"is_write_index": true
}
},
{
"add": {
"index": "idx2",
"alias": "my-logs"
}
}
]
}

PUT /_index_template/template
{
"index_patterns": ["my-logs*"],
"data_stream": { }
}
----
////

[source,console]
----
POST /_data_stream/_migrate/my-logs
----
// TEST[continued]

////
[source,console]
-----------------------------------
DELETE /_data_stream/my-logs
DELETE /_index_template/template
-----------------------------------
// TEST[continued]
////

[[indices-migrate-to-data-stream-request]]
==== {api-request-title}

`POST /_data_stream/_migrate/<alias>`

[[indices-migrate-to-data-stream-api-path-params]]
==== {api-path-parms-title}

`<alias>`::
+
--
(Required, string)
Name of the index alias to convert to a data stream. The alias must meet the
following criteria:

- The alias must have a <<aliases-write-index,write index>>.
- All indices for the alias have a `@timestamp` field mapping of a `date` or `date_nanos` field type.
- The alias must not have any <<filtered,filters>>.
- The alias must not use <<aliases-routing,custom routing>>.

If successful, the request removes the alias and creates a data stream with the
same name. The alias's indices become hidden backing indices for the stream. The
alias's write index becomes the stream's write index.
--