preview-transform.asciidoc 2.7 KB

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