deleteByQuery #
Deletes documents matching the provided search query.
This is a low level route intended to bypass Kuzzle actions on document deletion, notably:
- check document write limit
- trigger realtime notifications
deleteByQuery(index, collection, [query], [options]);
Argument | Type | Description |
---|---|---|
index | string | Index name |
collection | string | Collection name |
query | object | documents matching this search query will be deleted. Uses the ElasticSearch Query DSL syntax. |
options | object | Query options |
Options #
Additional query options
Options | Type (default) | Description |
---|---|---|
queuable | boolean ( true ) | If true , queues the request during downtime, until connected to Kuzzle again |
refresh | string ( "" ) | If set to wait_for , waits for the change to be reflected for search (up to 1s) |
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 #
Resolves to the number of the deleted documents.
Usage #
try {
const deleted = await kuzzle.bulk.deleteByQuery(
'nyc-open-data',
'yellow-taxi',
{
query: {
term: { capacity: 7 }
}
}
);
console.log(`Successfully deleted ${deleted} documents`);
} catch (error) {
console.error(error.message);
}
Edit this page on Github(opens new window)