put-transform.asciidoc 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[put-transform]]
  4. === Create {transform} API
  5. [subs="attributes"]
  6. ++++
  7. <titleabbrev>Create {transform}</titleabbrev>
  8. ++++
  9. Instantiates a {transform}.
  10. [[put-transform-request]]
  11. ==== {api-request-title}
  12. `PUT _transform/<transform_id>`
  13. [[put-transform-prereqs]]
  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 and `read`, `create_index`, and `index` privileges on the
  19. destination index. For more information, see <<security-privileges>> and
  20. <<built-in-roles>>.
  21. [[put-transform-desc]]
  22. ==== {api-description-title}
  23. This API defines a {transform}, which copies data from source indices,
  24. transforms it, and persists it into an entity-centric destination index. The
  25. entities are defined by the set of `group_by` fields in the `pivot` object. You
  26. can also think of the destination index as a two-dimensional tabular data
  27. structure (known as a {dataframe}). The ID for each document in the
  28. {dataframe} is generated from a hash of the entity, so there is a unique row
  29. per entity. For more information, see <<transforms>>.
  30. When the {transform} is created, a series of validations occur to
  31. ensure its success. For example, there is a check for the existence of the
  32. source indices and a check that the destination index is not part of the source
  33. index pattern. You can use the `defer_validation` parameter to skip these
  34. checks.
  35. Deferred validations are always run when the {transform} is started,
  36. with the exception of privilege checks. When {es} {security-features} are
  37. enabled, the {transform} remembers which roles the user that created
  38. it had at the time of creation and uses those same roles. If those roles do not
  39. have the required privileges on the source and destination indices, the
  40. {transform} fails when it attempts unauthorized operations.
  41. IMPORTANT: You must use {kib} or this API to create a {transform}.
  42. Do not put a {transform} directly into any
  43. `.transform-internal*` indices using the Elasticsearch index API.
  44. If {es} {security-features} are enabled, do not give users any
  45. privileges on `.transform-internal*` indices. If you used transforms
  46. prior 7.5, also do not give users any privileges on
  47. `.data-frame-internal*` indices.
  48. [[put-transform-path-parms]]
  49. ==== {api-path-parms-title}
  50. `<transform_id>`::
  51. (Required, string)
  52. include::{docdir}/rest-api/common-parms.asciidoc[tag=transform-id]
  53. [[put-transform-query-parms]]
  54. ==== {api-query-parms-title}
  55. `defer_validation`::
  56. (Optional, boolean) When `true`, deferrable validations are not run. This
  57. behavior may be desired if the source index does not exist until after the
  58. {transform} is created.
  59. [role="child_attributes"]
  60. [[put-transform-request-body]]
  61. ==== {api-request-body-title}
  62. `description`::
  63. (Optional, string) Free text description of the {transform}.
  64. //Begin dest
  65. `dest`::
  66. (Required, object)
  67. include::{docdir}/rest-api/common-parms.asciidoc[tag=dest]
  68. +
  69. .Properties of `dest`
  70. [%collapsible%open]
  71. ====
  72. `index`:::
  73. (Required, string)
  74. include::{docdir}/rest-api/common-parms.asciidoc[tag=dest-index]
  75. `pipeline`:::
  76. (Optional, string)
  77. include::{docdir}/rest-api/common-parms.asciidoc[tag=dest-pipeline]
  78. ====
  79. //End dest
  80. `frequency`::
  81. (Optional, <<time-units, time units>>)
  82. include::{docdir}/rest-api/common-parms.asciidoc[tag=frequency]
  83. //Begin pivot
  84. `pivot`::
  85. (Required, object)
  86. include::{docdir}/rest-api/common-parms.asciidoc[tag=pivot]
  87. +
  88. .Properties of `pivot`
  89. [%collapsible%open]
  90. ====
  91. `aggregations` or `aggs`:::
  92. (Required, object)
  93. include::{docdir}/rest-api/common-parms.asciidoc[tag=pivot-aggs]
  94. `group_by`:::
  95. (Required, object)
  96. include::{docdir}/rest-api/common-parms.asciidoc[tag=pivot-group-by]
  97. `max_page_search_size`:::
  98. (Optional, integer)
  99. include::{docdir}/rest-api/common-parms.asciidoc[tag=pivot-max-page-search-size]
  100. ====
  101. //End pivot
  102. //Begin source
  103. `source`::
  104. (Required, object)
  105. include::{docdir}/rest-api/common-parms.asciidoc[tag=source-transforms]
  106. +
  107. .Properties of `source`
  108. [%collapsible%open]
  109. ====
  110. `index`:::
  111. (Required, string or array)
  112. include::{docdir}/rest-api/common-parms.asciidoc[tag=source-index-transforms]
  113. `query`:::
  114. (Optional, object)
  115. include::{docdir}/rest-api/common-parms.asciidoc[tag=source-query-transforms]
  116. ====
  117. //End source
  118. //Begin sync
  119. `sync`::
  120. (Optional, object)
  121. include::{docdir}/rest-api/common-parms.asciidoc[tag=sync]
  122. +
  123. .Properties of `sync`
  124. [%collapsible%open]
  125. ====
  126. //Begin time
  127. `time`:::
  128. (Required, object)
  129. include::{docdir}/rest-api/common-parms.asciidoc[tag=sync-time]
  130. +
  131. .Properties of `time`
  132. [%collapsible%open]
  133. =====
  134. `delay`::::
  135. (Optional, <<time-units, time units>>)
  136. include::{docdir}/rest-api/common-parms.asciidoc[tag=sync-time-delay]
  137. `field`::::
  138. (Required, string)
  139. include::{docdir}/rest-api/common-parms.asciidoc[tag=sync-time-field]
  140. +
  141. --
  142. TIP: In general, it’s a good idea to use a field that contains the
  143. <<accessing-ingest-metadata,ingest timestamp>>. If you use a different field,
  144. you might need to set the `delay` such that it accounts for data transmission
  145. delays.
  146. --
  147. =====
  148. //End time
  149. ====
  150. //End sync
  151. [[put-transform-example]]
  152. ==== {api-examples-title}
  153. [source,console]
  154. --------------------------------------------------
  155. PUT _transform/ecommerce_transform
  156. {
  157. "source": {
  158. "index": "kibana_sample_data_ecommerce",
  159. "query": {
  160. "term": {
  161. "geoip.continent_name": {
  162. "value": "Asia"
  163. }
  164. }
  165. }
  166. },
  167. "pivot": {
  168. "group_by": {
  169. "customer_id": {
  170. "terms": {
  171. "field": "customer_id"
  172. }
  173. }
  174. },
  175. "aggregations": {
  176. "max_price": {
  177. "max": {
  178. "field": "taxful_total_price"
  179. }
  180. }
  181. }
  182. },
  183. "description": "Maximum priced ecommerce data by customer_id in Asia",
  184. "dest": {
  185. "index": "kibana_sample_data_ecommerce_transform",
  186. "pipeline": "add_timestamp_pipeline"
  187. },
  188. "frequency": "5m",
  189. "sync": {
  190. "time": {
  191. "field": "order_date",
  192. "delay": "60s"
  193. }
  194. }
  195. }
  196. --------------------------------------------------
  197. // TEST[setup:kibana_sample_data_ecommerce,add_timestamp_pipeline]
  198. When the {transform} is created, you receive the following results:
  199. [source,console-result]
  200. ----
  201. {
  202. "acknowledged" : true
  203. }
  204. ----