2019-03-20 13:19:41 -04:00
|
|
|
[role="xpack"]
|
|
|
|
[testenv="basic"]
|
|
|
|
[[preview-data-frame-transform]]
|
|
|
|
=== Preview {dataframe-transforms} API
|
2019-04-30 13:46:13 -04:00
|
|
|
|
|
|
|
[subs="attributes"]
|
2019-03-20 13:19:41 -04:00
|
|
|
++++
|
|
|
|
<titleabbrev>Preview {dataframe-transforms}</titleabbrev>
|
|
|
|
++++
|
|
|
|
|
|
|
|
Previews a {dataframe-transform}.
|
|
|
|
|
2019-07-10 17:39:38 -04:00
|
|
|
beta[]
|
|
|
|
|
2019-06-26 16:46:21 -04:00
|
|
|
[[preview-data-frame-transform-request]]
|
|
|
|
==== {api-request-title}
|
2019-03-20 13:19:41 -04:00
|
|
|
|
|
|
|
`POST _data_frame/transforms/_preview`
|
|
|
|
|
2019-06-26 16:46:21 -04:00
|
|
|
[[preview-data-frame-transform-prereq]]
|
|
|
|
==== {api-prereq-title}
|
2019-06-12 13:13:04 -04:00
|
|
|
|
2019-06-27 18:16:24 -04:00
|
|
|
* If the {es} {security-features} are enabled, you must have
|
2019-06-12 13:13:04 -04:00
|
|
|
`manage_data_frame_transforms` cluster privileges to use this API. The built-in
|
|
|
|
`data_frame_transforms_admin` role has these privileges. You must also have
|
|
|
|
`read` and `view_index_metadata` privileges on the source index for the
|
|
|
|
{dataframe-transform}. For more information, see
|
|
|
|
{stack-ov}/security-privileges.html[Security privileges] and
|
|
|
|
{stack-ov}/built-in-roles.html[Built-in roles].
|
2019-03-20 13:19:41 -04:00
|
|
|
|
2019-07-05 03:38:21 -04:00
|
|
|
[[preview-data-frame-transform-desc]]
|
|
|
|
==== {api-description-title}
|
|
|
|
|
|
|
|
This API generates a preview of the results that you will get when you run the
|
|
|
|
<<put-data-frame-transform,create {dataframe-transforms} API>> with the same
|
|
|
|
configuration. It returns a maximum of 100 results. The calculations are based
|
|
|
|
on all the current data in the source index.
|
|
|
|
|
2019-06-26 16:46:21 -04:00
|
|
|
[[preview-data-frame-transform-request-body]]
|
|
|
|
==== {api-request-body-title}
|
|
|
|
|
2019-07-10 17:39:38 -04:00
|
|
|
`source`::
|
2019-07-18 10:58:28 -04:00
|
|
|
(Required, object) The source configuration, which has the following
|
|
|
|
properties:
|
|
|
|
|
|
|
|
`index`:::
|
|
|
|
(Required, string or array) The _source indices_ for the
|
|
|
|
{dataframe-transform}. It can be a single index, an index pattern (for
|
|
|
|
example, `"myindex*"`), or an array of indices (for example,
|
|
|
|
`["index1", "index2"]`).
|
|
|
|
|
|
|
|
`query`:::
|
|
|
|
(Optional, object) A query clause that retrieves a subset of data from the
|
|
|
|
source index. See <<query-dsl>>.
|
2019-06-26 16:46:21 -04:00
|
|
|
|
2019-07-10 17:39:38 -04:00
|
|
|
`pivot`::
|
2019-07-12 11:26:31 -04:00
|
|
|
(Required, object) Defines the pivot function `group by` fields and the
|
2019-07-10 17:39:38 -04:00
|
|
|
aggregation to reduce the data. See <<data-frame-transform-pivot>>.
|
2019-07-05 03:38:21 -04:00
|
|
|
|
|
|
|
[[preview-data-frame-transform-response]]
|
|
|
|
==== {api-response-body-title}
|
|
|
|
|
|
|
|
`preview`::
|
|
|
|
(array) An array of documents. In particular, they are the JSON
|
|
|
|
representation of the documents that would be created in the destination index
|
|
|
|
by the {dataframe-transform}.
|
2019-03-20 13:19:41 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
==== {api-examples-title}
|
2019-03-20 13:19:41 -04:00
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
POST _data_frame/transforms/_preview
|
|
|
|
{
|
2019-05-03 11:30:41 -04:00
|
|
|
"source": {
|
|
|
|
"index": "kibana_sample_data_ecommerce"
|
|
|
|
},
|
2019-03-20 13:19:41 -04:00
|
|
|
"pivot": {
|
|
|
|
"group_by": {
|
|
|
|
"customer_id": {
|
|
|
|
"terms": {
|
|
|
|
"field": "customer_id"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"aggregations": {
|
|
|
|
"max_price": {
|
|
|
|
"max": {
|
|
|
|
"field": "taxful_total_price"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
|
|
|
// TEST[skip:set up sample data]
|
|
|
|
|
|
|
|
The data that is returned for this example is as follows:
|
|
|
|
[source,js]
|
|
|
|
----
|
|
|
|
{
|
|
|
|
"preview" : [
|
|
|
|
{
|
|
|
|
"max_price" : 171.0,
|
|
|
|
"customer_id" : "10"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"max_price" : 233.0,
|
|
|
|
"customer_id" : "11"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"max_price" : 200.0,
|
|
|
|
"customer_id" : "12"
|
|
|
|
}
|
|
|
|
...
|
2019-07-02 07:52:14 -04:00
|
|
|
],
|
|
|
|
"mappings": {
|
|
|
|
"properties": {
|
|
|
|
"max_price": {
|
|
|
|
"type": "double"
|
|
|
|
},
|
|
|
|
"customer_id": {
|
|
|
|
"type": "keyword"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-03-20 13:19:41 -04:00
|
|
|
}
|
|
|
|
----
|
|
|
|
// NOTCONSOLE
|