updateByQuery #
Available since 2.11.0
Updates documents matching the provided search query.
This is a low level route intended to bypass Kuzzle actions on document update, notably:
- Check document write limit
- Inject Kuzzle metadata
- Trigger realtime notifications
Under the hood, this action uses Elastic Search scripting feature.
Query Syntax #
HTTP #
URL: http://kuzzle:7512/<index>/<collection>/_bulk/_query[?refresh=wait_for]
Method: PATCH
Body:
{
"query": {
// query to match documents
},
"changes": {
// documents changes
}
}
Other protocols #
{
"index": "<index>",
"collection": "<collection>",
"controller": "bulk",
"action": "updateByQuery",
"refresh": "wait_for",
"body": {
"query": {
// to match documents
},
"changes": {
// documents changes
}
}
}
Kourou #
kourou bulk:updateByQuery <index> <collection> <body>
Arguments #
collection
: collection nameindex
: index name
Optional #
refresh
: if set towait_for
, Kuzzle will not respond until the deleted documents are removed from the search indexes
Body properties #
query
: documents matching this search query will be updated. Uses the ElasticSearch Query DSL syntax.changes
: partial changes to apply to the documents
Even though changes
supports deeply nested fields, there are some limitations. Therefore, you will not be able to apply partial changes to an array and will need to replace the whole array.
Response #
Returns the number of updated documents.
{
"status": 200,
"error": null,
"index": "<index>",
"collection": "<collection>",
"controller": "bulk",
"action": "updateByQuery",
"requestId": "<unique request identifier>",
"result": {
"updated": 42
}
Edit this page on Github(opens new window)