preview-transform.asciidoc 4.0 KB

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