Spaces method and path for this operation:
post /s/{space_id}/api/data_views/data_view/{viewId}/runtime_field
Refer to Spaces for more information.
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.
POST
/api/data_views/data_view/{viewId}/runtime_field
curl
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())"}}}'
POST kbn://api/data_views/data_view/{viewId}/runtime_field
{"name":"hour_of_day","runtimeField":{"type":"long","script":{"source":"emit(doc['timestamp'].value.getHour())"}}}
Request example
Create a long-type runtime field that emits a value derived from the foo source field.
{
"name": "runtimeFoo",
"runtimeField": {
"script": {
"source": "emit(doc[\"foo\"].value)"
},
"type": "long"
}
}