update_by_query
Modify documents in an Elasticsearch index using a query and script, handling conflicts and refresh options for controlled updates.
Instructions
Update documents in an Elasticsearch index based on a query
Input Schema
Name | Required | Description | Default |
---|---|---|---|
conflicts | No | What to do when version conflicts occur during the update | |
index | Yes | Name of the Elasticsearch index to update documents in | |
maxDocs | No | Limit the number of documents to update | |
query | Yes | Elasticsearch query to select documents for updating | |
refresh | No | Should the index be refreshed after the update (defaults to true) | |
script | Yes | Script to execute on matching documents |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"conflicts": {
"description": "What to do when version conflicts occur during the update",
"enum": [
"abort",
"proceed"
],
"type": "string"
},
"index": {
"description": "Name of the Elasticsearch index to update documents in",
"minLength": 1,
"type": "string"
},
"maxDocs": {
"description": "Limit the number of documents to update",
"exclusiveMinimum": 0,
"type": "integer"
},
"query": {
"additionalProperties": {},
"description": "Elasticsearch query to select documents for updating",
"type": "object"
},
"refresh": {
"default": true,
"description": "Should the index be refreshed after the update (defaults to true)",
"type": "boolean"
},
"script": {
"additionalProperties": false,
"description": "Script to execute on matching documents",
"properties": {
"params": {
"additionalProperties": {},
"description": "Optional parameters for the script",
"type": "object"
},
"source": {
"description": "Painless script source for the update operation",
"minLength": 1,
"type": "string"
}
},
"required": [
"source"
],
"type": "object"
}
},
"required": [
"index",
"query",
"script"
],
"type": "object"
}