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 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) |
queuable | boolean ( true ) | If true , queues the request during downtime, until connected to Kuzzle again |
timeout | number ( -1 ) | Time (in ms) during which a request will still be waited to be resolved. Set it -1 if you want to wait indefinitely |
triggerEvents | boolean ( false ) | If set to true , will trigger events even if using Embeded SDK. You should always ensure that your events/pipes does not create an infinite loop. Available since Kuzzle 2.31.0 |
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);
}
Edit this page on Github(opens new window)