SDK
SDK Javascript v6.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

deleteByQuery #

Deletes 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.


deleteByQuery(index, collection, [query], [options]);
ArgumentTypeDescription
index
string
Index name
collection
string
Collection name
query
object
Query to match
options
object
Query options

Options #

Additional query options

OptionsType
(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)

Resolves #

Resolves to an array of strings containing the deleted document ids.

Usage #

try {
  const deleted = await kuzzle.document.deleteByQuery(
    'nyc-open-data',
    'yellow-taxi',
    {
      query: {
        term: { capacity: 7 }
      }
    }
  );
  console.log(`Successfully deleted ${deleted.length} documents`);
} catch (error) {
  console.error(error.message);
}