Spaces method and path for this operation:
put /s/{space_id}/api/data_views/data_view/{viewId}/runtime_field
Refer to Spaces for more information.
Create or update a runtime field for a data view. If the runtime field already exists, it is replaced with the new definition.
PUT
/api/data_views/data_view/{viewId}/runtime_field
curl
curl \
-X PUT "${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())"}}}'
PUT 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"
}
}