deleteByQuery

Deletes documents matching the provided search query.

Kuzzle uses the ElasticSearch Query DSL syntax.

Signature

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

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

Arguments

Argument Type Description
index
const std::string&
Index name
collection
const std::string&
Collection name
query
const std::string&
JSON string representing query to match
options
kuzzleio::query_options*
Query options

options

Additional query options

Options 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 ids of deleted documents.

Exceptions

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

Usage

Copied to clipboard!
try {
  std::vector<std::string> response =
    kuzzle->document->deleteByQuery("nyc-open-data", "yellow-taxi", R"({
      "query": {
        "term": {
          "capacity": 7
        }
      }
    })");

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