preview-transform.asciidoc 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[preview-transform]]
  4. === Preview {transform} API
  5. [subs="attributes"]
  6. ++++
  7. <titleabbrev>Preview {transform}</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 `manage_transform`
  17. cluster privileges to use this API. The built-in `transform_admin` role has
  18. these privileges. You must also have `read` and `view_index_metadata` privileges
  19. on the source index for the {transform}. For more information, see
  20. <<security-privileges>> and <<built-in-roles>>.
  21. [[preview-transform-desc]]
  22. ==== {api-description-title}
  23. This API generates a preview of the results that you will get when you run the
  24. <<put-transform,create {transforms} API>> with the same
  25. configuration. It returns a maximum of 100 results. The calculations are based
  26. on all the current data in the source index.
  27. [[preview-transform-request-body]]
  28. ==== {api-request-body-title}
  29. `description`::
  30. (Optional, string) Free text description of the {transform}.
  31. `dest`::
  32. (Optional, object)
  33. include::{docdir}/rest-api/common-parms.asciidoc[tag=dest]
  34. `dest`.`index`:::
  35. (Optional, string)
  36. include::{docdir}/rest-api/common-parms.asciidoc[tag=dest-index]
  37. `dest`.`pipeline`:::
  38. (Optional, string)
  39. include::{docdir}/rest-api/common-parms.asciidoc[tag=dest-pipeline]
  40. `frequency`::
  41. (Optional, <<time-units, time units>>)
  42. include::{docdir}/rest-api/common-parms.asciidoc[tag=frequency]
  43. `pivot`::
  44. (Required, object)
  45. include::{docdir}/rest-api/common-parms.asciidoc[tag=pivot]
  46. `pivot`.`aggregations` or `aggs`:::
  47. (Required, object)
  48. include::{docdir}/rest-api/common-parms.asciidoc[tag=pivot-aggs]
  49. `pivot`.`group_by`:::
  50. (Required, object)
  51. include::{docdir}/rest-api/common-parms.asciidoc[tag=pivot-group-by]
  52. `pivot`.`max_page_search_size`:::
  53. (Optional, integer)
  54. include::{docdir}/rest-api/common-parms.asciidoc[tag=pivot-max-page-search-size]
  55. `source`::
  56. (Required, object)
  57. include::{docdir}/rest-api/common-parms.asciidoc[tag=source-transforms]
  58. `source`.`index`:::
  59. (Required, string or array)
  60. include::{docdir}/rest-api/common-parms.asciidoc[tag=source-index-transforms]
  61. `source`.`query`:::
  62. (Optional, object)
  63. include::{docdir}/rest-api/common-parms.asciidoc[tag=source-query-transforms]
  64. `sync`::
  65. (Optional, object)
  66. include::{docdir}/rest-api/common-parms.asciidoc[tag=sync]
  67. `sync`.`time`:::
  68. (Optional, object)
  69. include::{docdir}/rest-api/common-parms.asciidoc[tag=sync-time]
  70. `sync`.`time`.`delay`::::
  71. (Optional, <<time-units, time units>>)
  72. include::{docdir}/rest-api/common-parms.asciidoc[tag=sync-time-delay]
  73. `sync`.`time`.`field`::::
  74. (Optional, string)
  75. include::{docdir}/rest-api/common-parms.asciidoc[tag=sync-time-field]
  76. [[preview-transform-response]]
  77. ==== {api-response-body-title}
  78. `preview`::
  79. (array) An array of documents. In particular, they are the JSON
  80. representation of the documents that would be created in the destination index
  81. by the {transform}.
  82. ==== {api-examples-title}
  83. [source,console]
  84. --------------------------------------------------
  85. POST _transform/_preview
  86. {
  87. "source": {
  88. "index": "kibana_sample_data_ecommerce"
  89. },
  90. "pivot": {
  91. "group_by": {
  92. "customer_id": {
  93. "terms": {
  94. "field": "customer_id"
  95. }
  96. }
  97. },
  98. "aggregations": {
  99. "max_price": {
  100. "max": {
  101. "field": "taxful_total_price"
  102. }
  103. }
  104. }
  105. }
  106. }
  107. --------------------------------------------------
  108. // TEST[skip:set up sample data]
  109. The data that is returned for this example is as follows:
  110. [source,js]
  111. ----
  112. {
  113. "preview" : [
  114. {
  115. "max_price" : 171.0,
  116. "customer_id" : "10"
  117. },
  118. {
  119. "max_price" : 233.0,
  120. "customer_id" : "11"
  121. },
  122. {
  123. "max_price" : 200.0,
  124. "customer_id" : "12"
  125. }
  126. ...
  127. ],
  128. "mappings": {
  129. "properties": {
  130. "max_price": {
  131. "type": "double"
  132. },
  133. "customer_id": {
  134. "type": "keyword"
  135. }
  136. }
  137. }
  138. }
  139. ----
  140. // NOTCONSOLE