put-transform.asciidoc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. ==== Request
  12. `PUT _data_frame/transforms/<data_frame_transform_id>`
  13. ===== Description
  14. IMPORTANT: You must use {kib} or this API to create a {dataframe-transform}.
  15. Do not put a {dataframe-transform} directly into any
  16. `.data-frame-internal*` indices using the Elasticsearch index API.
  17. If {es} {security-features} are enabled, do not give users any
  18. privileges on `.data-frame-internal*` indices.
  19. ==== Path Parameters
  20. `data_frame_transform_id` (required)::
  21. (string) Identifier for the {dataframe-transform}. This identifier can contain
  22. lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. It
  23. must start and end with alphanumeric characters.
  24. ==== Request Body
  25. `source` (required):: (object) The source configuration, consisting of `index` and optionally
  26. a `query`.
  27. `dest` (required):: (object) The destination configuration, consisting of `index`.
  28. `pivot`:: (object) Defines the pivot function `group by` fields and the aggregation to
  29. reduce the data. See <<data-frame-transform-pivot, data frame transform pivot objects>>.
  30. `description`:: Optional free text description of the data frame transform
  31. ==== Authorization
  32. If the {es} {security-features} are enabled, you must have
  33. `manage_data_frame_transforms` cluster privileges to use this API. The built-in
  34. `data_frame_transforms_admin` role has these privileges. You must also
  35. have `read` and `view_index_metadata` privileges on the source index and `read`,
  36. `create_index`, and `index` privileges on the destination index. For more
  37. information, see {stack-ov}/security-privileges.html[Security privileges] and
  38. {stack-ov}/built-in-roles.html[Built-in roles].
  39. ==== Examples
  40. The following example creates a {dataframe-transform} for the {kib} eCommerce
  41. sample data:
  42. [source,js]
  43. --------------------------------------------------
  44. PUT _data_frame/transforms/ecommerce_transform
  45. {
  46. "source": {
  47. "index": "kibana_sample_data_ecommerce",
  48. "query": {
  49. "term": {
  50. "geoip.continent_name": {
  51. "value": "Asia"
  52. }
  53. }
  54. }
  55. },
  56. "dest": {
  57. "index": "kibana_sample_data_ecommerce_transform"
  58. },
  59. "pivot": {
  60. "group_by": {
  61. "customer_id": {
  62. "terms": {
  63. "field": "customer_id"
  64. }
  65. }
  66. },
  67. "aggregations": {
  68. "max_price": {
  69. "max": {
  70. "field": "taxful_total_price"
  71. }
  72. }
  73. }
  74. },
  75. "description": "Maximum priced ecommerce data by customer_id in Asia"
  76. }
  77. --------------------------------------------------
  78. // CONSOLE
  79. // TEST[setup:kibana_sample_data_ecommerce]
  80. When the transform is created, you receive the following results:
  81. [source,js]
  82. ----
  83. {
  84. "acknowledged" : true
  85. }
  86. ----
  87. // TESTRESPONSE