migrate-to-data-stream.asciidoc 2.1 KB

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