Create a runtime field
Base URL
https://{kibana_url}
Auth
Create a runtime field for a data view. Runtime fields are computed at query time using a Painless script and do not require reindexing. If no script is provided, the runtime field returns the corresponding value from the document _source.
Expand all
space_id
string
optional
An identifier for the space. If space_id is not provided in the URL, the default space is used. Refer to Spaces for more information.
viewId
string
required
An identifier for the data view.
Example:
ff959d40-b880-11e8-a6d9-e546fe2bba5f
Cross-site request forgery protection
{
}
name
string
required
The name for a runtime field.
runtimeField
object
required
The runtime field definition object.
200
Indicates a successful call.
application/json
Thank you for your feedback.
Base URL
https://{kibana_url}
Examples
Example
2 languages
Create a runtime field.
2 languages
Request
Console
1 / 2 languages
‹
›
1
2
POST kbn://api/data_views/data_view/{viewId}/runtime_field
{"name":"hour_of_day","runtimeField":{"type":"long","script":{"source":"emit(doc['timestamp'].value.getHour())"}}}
1
2
3
4
5
6
curl \
-X POST "${KIBANA_URL}/api/data_views/data_view/${DATA_VIEW_ID}/runtime_field" \
-H "Authorization: ApiKey ${API_KEY}" \
-H "kbn-xsrf: true" \
-H "Content-Type: application/json" \
-d '{"name":"hour_of_day","runtimeField":{"type":"long","script":{"source":"emit(doc['"'"'timestamp'"'"'].value.getHour())"}}}'
Request
Console
1 / 2 languages
‹
›
Create a long-type runtime field that emits a value derived from the foo source field.
Show more
1
2
3
4
5
6
7
8
9
10
POST kbn:/api/data_views/data_view/VIEW_ID/runtime_field
{
"name": "runtimeFoo",
"runtimeField": {
"script": {
"source": "emit(doc[\u0022foo\u0022].value)"
},
"type": "long"
}
}
Generated from the API spec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
curl \
-X POST "${KIBANA_URL}/api/data_views/data_view/${VIEW_ID}/runtime_field" \
-H "Authorization: ApiKey ${API_KEY}" \
-H "kbn-xsrf: true" \
-H "Content-Type: application/json" \
-d '{
"name": "runtimeFoo",
"runtimeField": {
"script": {
"source": "emit(doc[\u0022foo\u0022].value)"
},
"type": "long"
}
}'"'"'timestamp'"'"'].value.getHour())"}}}'
Generated from the API spec
Response
The response includes the newly created runtime field as an array and the full updated data view object.
Show more
1
2
3
4
5
6
7
8
{
"data_view": {
"...": "null"
},
"fields": [
"..."
]
}