deleteDocument #
Delete a stored document, or all stored documents matching a search filter.
There is a small delay between the time a document is deleted and it being reflected in the search layer (usually a couple of seconds). That means that a document that was just deleted might still be returned by this function.
deleteDocument(documentId, [options], [callback]) #
Arguments | Type | Description |
---|---|---|
documentId | string | Unique document identifier |
options | JSON object | Optional parameters |
callback | function | Optional callback |
deleteDocument(filters, [options], [callback]) #
Arguments | Type | Description |
---|---|---|
filters | JSON object | Filters in ElasticSearch Query DSL format |
options | JSON object | Optional parameters |
callback | function | Optional callback |
Options #
Option | Type | Description | Default |
---|---|---|---|
volatile | JSON object | Additional information passed to notifications to other users | null |
queuable | boolean | Make this request queuable or not | true |
refresh | string | If set to wait_for , Kuzzle will wait for the persistence layer to finish indexing (available with Elasticsearch 5.x and above) | undefined |
Return Value #
Returns the Collection
object to allow chaining.
Callback Response #
Returns an array
containing the ids of the deleted documents.
Usage #
// Deleting one document
kuzzle
.collection("collection", "index")
.deleteDocument("document unique ID", new ResponseListener<String>() {
@Override
public void onSuccess(String object) {
// The resulting string contains the deleted document ID
}
@Override
public void onError(JSONObject error) {
// Handle error
}
});
// Deleting multiple documents
JSONObject equalsFilter = new JSONObject()
.put("filter", new JSONObject()
.put("equals",
new JSONObject().put("title", "foo")
));
kuzzle
.collection("collection", "index")
.deleteDocument(equalsFilter, new ResponseListener<String[]>() {
@Override
public void onSuccess(String[] object) {
// The resulting object contains the list of deleted document IDs
}
@Override
public void onError(JSONObject error) {
// Handle error
}
});
Callback response:
["AVCoeBkimsySTKTfa8AX"]
Edit this page on Github(opens new window)