delete

Deletes a document.

The optional parameter refresh can be used with the value wait_for in order to wait for the document to be indexed (and to no longer be available in search).


Copied to clipboard!
delete (index, collection, id, [options]);
Argument Type Description
index
string
Index name
collection
string
Collection name
id
string
Document ID
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)

Resolves

Resolves to the id of the deleted document.

Usage

Copied to clipboard!
try {
  const id = await kuzzle.document.delete('nyc-open-data', 'yellow-taxi', 'some-id');

  if (id === 'some-id') {
    console.log('Success');
  }
} catch (error) {
  console.error(error.message);
}