preview-transform.asciidoc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[preview-data-frame-transform]]
  4. === Preview {dataframe-transforms} API
  5. [subs="attributes"]
  6. ++++
  7. <titleabbrev>Preview {dataframe-transforms}</titleabbrev>
  8. ++++
  9. beta[]
  10. Previews a {dataframe-transform}.
  11. [discrete]
  12. [[preview-data-frame-transform-request]]
  13. ==== {api-request-title}
  14. `POST _data_frame/transforms/_preview`
  15. [discrete]
  16. [[preview-data-frame-transform-prereq]]
  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 have
  21. `read` and `view_index_metadata` privileges on the source index for the
  22. {dataframe-transform}. For more information, see
  23. {stack-ov}/security-privileges.html[Security privileges] and
  24. {stack-ov}/built-in-roles.html[Built-in roles].
  25. [discrete]
  26. [[preview-data-frame-transform-desc]]
  27. ==== {api-description-title}
  28. This API generates a preview of the results that you will get when you run the
  29. <<put-data-frame-transform,create {dataframe-transforms} API>> with the same
  30. configuration. It returns a maximum of 100 results. The calculations are based
  31. on all the current data in the source index.
  32. [discrete]
  33. [[preview-data-frame-transform-request-body]]
  34. ==== {api-request-body-title}
  35. `source` (Required)::
  36. (object) The source index or index pattern.
  37. `pivot` (Required)::
  38. (object) Defines the pivot function `group by` fields and the aggregation to
  39. reduce the data. See <<data-frame-transform-pivot>>.
  40. [discrete]
  41. [[preview-data-frame-transform-response]]
  42. ==== {api-response-body-title}
  43. `preview`::
  44. (array) An array of documents. In particular, they are the JSON
  45. representation of the documents that would be created in the destination index
  46. by the {dataframe-transform}.
  47. [discrete]
  48. ==== {api-examples-title}
  49. [source,js]
  50. --------------------------------------------------
  51. POST _data_frame/transforms/_preview
  52. {
  53. "source": {
  54. "index": "kibana_sample_data_ecommerce"
  55. },
  56. "pivot": {
  57. "group_by": {
  58. "customer_id": {
  59. "terms": {
  60. "field": "customer_id"
  61. }
  62. }
  63. },
  64. "aggregations": {
  65. "max_price": {
  66. "max": {
  67. "field": "taxful_total_price"
  68. }
  69. }
  70. }
  71. }
  72. }
  73. --------------------------------------------------
  74. // CONSOLE
  75. // TEST[skip:set up sample data]
  76. The data that is returned for this example is as follows:
  77. [source,js]
  78. ----
  79. {
  80. "preview" : [
  81. {
  82. "max_price" : 171.0,
  83. "customer_id" : "10"
  84. },
  85. {
  86. "max_price" : 233.0,
  87. "customer_id" : "11"
  88. },
  89. {
  90. "max_price" : 200.0,
  91. "customer_id" : "12"
  92. }
  93. ...
  94. ],
  95. "mappings": {
  96. "properties": {
  97. "max_price": {
  98. "type": "double"
  99. },
  100. "customer_id": {
  101. "type": "keyword"
  102. }
  103. }
  104. }
  105. }
  106. ----
  107. // NOTCONSOLE