migrate-to-data-stream.asciidoc 1.9 KB

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