preview-transform.asciidoc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 configuration, which has the following
  33. properties:
  34. `index`:::
  35. (Required, string or array) The _source indices_ for the
  36. {dataframe-transform}. It can be a single index, an index pattern (for
  37. example, `"myindex*"`), or an array of indices (for example,
  38. `["index1", "index2"]`).
  39. `query`:::
  40. (Optional, object) A query clause that retrieves a subset of data from the
  41. source index. See <<query-dsl>>.
  42. `pivot`::
  43. (Required, object) Defines the pivot function `group by` fields and the
  44. aggregation to reduce the data. See <<data-frame-transform-pivot>>.
  45. [[preview-data-frame-transform-response]]
  46. ==== {api-response-body-title}
  47. `preview`::
  48. (array) An array of documents. In particular, they are the JSON
  49. representation of the documents that would be created in the destination index
  50. by the {dataframe-transform}.
  51. ==== {api-examples-title}
  52. [source,js]
  53. --------------------------------------------------
  54. POST _data_frame/transforms/_preview
  55. {
  56. "source": {
  57. "index": "kibana_sample_data_ecommerce"
  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. }
  76. --------------------------------------------------
  77. // CONSOLE
  78. // TEST[skip:set up sample data]
  79. The data that is returned for this example is as follows:
  80. [source,js]
  81. ----
  82. {
  83. "preview" : [
  84. {
  85. "max_price" : 171.0,
  86. "customer_id" : "10"
  87. },
  88. {
  89. "max_price" : 233.0,
  90. "customer_id" : "11"
  91. },
  92. {
  93. "max_price" : 200.0,
  94. "customer_id" : "12"
  95. }
  96. ...
  97. ],
  98. "mappings": {
  99. "properties": {
  100. "max_price": {
  101. "type": "double"
  102. },
  103. "customer_id": {
  104. "type": "keyword"
  105. }
  106. }
  107. }
  108. }
  109. ----
  110. // NOTCONSOLE