Upsert Runtime Field
upsert_runtime_fieldCreate or replace a runtime field on a data view by view id, computing values at search time with a Painless script. Returns created status and the previous definition for undo.
Instructions
Create or replace a runtime field on a data view, by view id (from
list_data_views): a field computed at search time by a Painless
script that calls emit(...) with a value of type (e.g.
"emit(doc['timestamp'].value.getHour())" for a long). Without a script
the field reads the _source value of the same name. Kibana does NOT
compile the script: one that does not compile, or emits another type,
makes every search that Kibana runs on the data view fail (Discover,
and visualizations that use the view) until you fix it with another
call or remove it with delete_runtime_field. A name the view already
has as a mapped field is refused (describe_data_view lists its
fields); composite runtime fields are not managed here. A replacement
keeps the field's custom label and description. Returns the stored
field (name, type, script), created, and previous — the
definition replaced (null on a create): pass its type and script
back to undo.
space targets a Kibana space by id (default: the default space).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"view_id": "<view_id>",
"name": "<name>",
"type": "<type>"
},
"name": "upsert_runtime_field"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| type | Yes | ||
| space | No | ||
| script | No | ||
| view_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||