update_by_query
Update documents matching a query in an index using a Painless script, with asynchronous task tracking and explicit confirmation for destructive operations.
Instructions
Update documents in place by query, using a painless script. DESTRUCTIVE and irreversible. A query is mandatory: match_all is refused so you cannot rewrite a whole index by accident. Runs asynchronously; returns a task_id to poll with get_task. Reports how many documents match before updating. Requires writes enabled, ES_MCP_ALLOW_DESTRUCTIVE=true, and confirm=true.
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": {
"index": "<index>",
"query": "<query>",
"script_source": "<script_source>"
},
"name": "update_by_query"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| index | Yes | ||
| query | Yes | ||
| slices | No | auto | |
| confirm | No | ||
| script_params | No | ||
| script_source | Yes | ||
| requests_per_second | No | ||
| wait_for_completion | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |