mDelete

Deletes multiple documents.

Throws a partial error (error code 206) if one or more document deletions fail.

The optional parameter refresh can be used with the value wait_for in order to wait for the document indexation (indexed documents are available for search).

Signature

Copied to clipboard!
std::vector<std::string> mDelete(
    const std::string& index,
    const std::string& collection,
    const std::vector<std::string>& ids);

std::vector<std::string> mDelete(
    const std::string& index,
    const std::string& collection,
    const std::vector<std::string>& ids,
    const kuzzleio::query_options& options);

Arguments

Argument Type Description
index
const std::string&
Index name
collection
const std::string&
Collection name
ids
std::vector<std::string>
IDs of the documents to delete
options
kuzzleio::query_options*
Query options

options

Additional query options

Option Type
(default)
Description
queuable
bool

(true)
If true, queues the request during downtime, until connected to Kuzzle again
refresh
const std::string&
("")
If set to wait_for, waits for the change to be reflected for search (up to 1s)

Return

A vector containing the deleted documents IDs.

Exceptions

Throws a kuzzleio::KuzzleException if there is an error. See how to handle errors.

Usage

Copied to clipboard!
std::vector<std::string> ids;

ids.push_back("some-id");
ids.push_back("some-other-id");

try {
  kuzzle->document->create("nyc-open-data", "yellow-taxi", "some-id", "{}");
  kuzzle->document->create("nyc-open-data", "yellow-taxi", "some-other-id", "{}");

  std::vector<std::string> deleted = kuzzle->document->mDelete(
    "nyc-open-data",
    "yellow-taxi",
    ids);

  std::cout << "Successfully deleted " << deleted.size() << " documents" << std::endl;
} catch (kuzzleio::KuzzleException& e) {
  std::cerr << e.what() << std::endl;
}