updateByQuery #
Available since Kuzzle 2.11.0
Available since 7.7.1
Updates documents matching the provided search query.
Kuzzle uses the ElasticSearch Query DSL (opens new window) syntax.
An empty or null query will match all documents in the collection.
updateByQuery(index, collection, query, changes, [options])
Argument | Type | Description |
---|---|---|
index | string | Index name |
collection | string | Collection name |
query | object | Query to match |
changes | object | Partial changes to apply to the documents |
options | object | Optional parameters |
options #
Additional query options.
Options | Type (default) | Description |
---|---|---|
refresh | string ( "" ) | If set to wait_for , waits for the change to be reflected for search (up to 1s) |
timeout | number | Time (in ms) during which a request will still be waited to be resolved. Set it -1 if you want to wait indefinitely |
Resolves #
Returns the number of updated documents.
Usage #
try {
const result = await kuzzle.bulk.updateByQuery(
'nyc-open-data',
'yellow-taxi',
{
match: {
capacity: 4
}
},
{ capacity: 42 });
console.log(result);
/**
* 2
*/
} catch (error) {
console.log(error.message);
}