put-transform.asciidoc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[put-data-frame-transform]]
  4. === Create {dataframe-transforms} API
  5. [subs="attributes"]
  6. ++++
  7. <titleabbrev>Create {dataframe-transforms}</titleabbrev>
  8. ++++
  9. beta[]
  10. Instantiates a {dataframe-transform}.
  11. [discrete]
  12. [[put-data-frame-transform-request]]
  13. ==== {api-request-title}
  14. `PUT _data_frame/transforms/<data_frame_transform_id>`
  15. [discrete]
  16. [[put-data-frame-transform-prereqs]]
  17. ==== {api-prereq-title}
  18. If the {es} {security-features} are enabled, you must have
  19. `manage_data_frame_transforms` cluster privileges to use this API. The built-in
  20. `data_frame_transforms_admin` role has these privileges. You must also
  21. have `read` and `view_index_metadata` privileges on the source index and `read`,
  22. `create_index`, and `index` privileges on the destination index. For more
  23. information, see {stack-ov}/security-privileges.html[Security privileges] and
  24. {stack-ov}/built-in-roles.html[Built-in roles].
  25. [discrete]
  26. [[put-data-frame-transform-desc]]
  27. ===== {api-description-title}
  28. IMPORTANT: You must use {kib} or this API to create a {dataframe-transform}.
  29. Do not put a {dataframe-transform} directly into any
  30. `.data-frame-internal*` indices using the Elasticsearch index API.
  31. If {es} {security-features} are enabled, do not give users any
  32. privileges on `.data-frame-internal*` indices.
  33. [discrete]
  34. [[put-data-frame-transform-path-parms]]
  35. ==== {api-path-parms-title}
  36. `<data_frame_transform_id>` (Required)::
  37. (string) Identifier for the {dataframe-transform}. This identifier can contain
  38. lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. It
  39. must start and end with alphanumeric characters.
  40. [discrete]
  41. [[put-data-frame-transform-request-body]]
  42. ==== {api-request-body-title}
  43. `description` (Optional)::
  44. (string) Free text description of the {dataframe-transform}.
  45. `dest` (Required)::
  46. (object) The destination configuration, which consists of `index` and
  47. optionally a `pipeline` id.
  48. `pivot` (Optional)::
  49. (object) Defines the pivot function `group by` fields and the aggregation to
  50. reduce the data. See <<data-frame-transform-pivot>>.
  51. `source` (Required)::
  52. (object) The source configuration, which consists of `index` and optionally
  53. a `query`.
  54. [discrete]
  55. [[put-data-frame-transform-example]]
  56. ==== {api-example-title}
  57. [source,js]
  58. --------------------------------------------------
  59. PUT _data_frame/transforms/ecommerce_transform
  60. {
  61. "source": {
  62. "index": "kibana_sample_data_ecommerce",
  63. "query": {
  64. "term": {
  65. "geoip.continent_name": {
  66. "value": "Asia"
  67. }
  68. }
  69. }
  70. },
  71. "dest": {
  72. "index": "kibana_sample_data_ecommerce_transform",
  73. "pipeline": "add_timestamp_pipeline"
  74. },
  75. "pivot": {
  76. "group_by": {
  77. "customer_id": {
  78. "terms": {
  79. "field": "customer_id"
  80. }
  81. }
  82. },
  83. "aggregations": {
  84. "max_price": {
  85. "max": {
  86. "field": "taxful_total_price"
  87. }
  88. }
  89. }
  90. },
  91. "description": "Maximum priced ecommerce data by customer_id in Asia"
  92. }
  93. --------------------------------------------------
  94. // CONSOLE
  95. // TEST[skip: https://github.com/elastic/elasticsearch/issues/43271]
  96. When the transform is created, you receive the following results:
  97. [source,js]
  98. ----
  99. {
  100. "acknowledged" : true
  101. }
  102. ----
  103. // TESTRESPONSE