preview-transform.asciidoc 2.9 KB

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