put-transform.asciidoc 6.6 KB

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