SDK
SDK C# v2.x
2

DeleteByQueryAsync #

Deletes documents matching the provided search query.

Kuzzle uses the ElasticSearch Query DSL syntax.

Arguments #

public async Task<JArray> DeleteByQueryAsync(
  string index, 
  string collection, 
  JObject query);

ArgumentTypeDescription
index
string
Index name
collection
string
Collection name
query
JObject
JObject representing the query to match

Return #

A JArray containing the IDs of deleted documents.

Exceptions #

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

Usage #

try {
  JArray ids =
    await kuzzle.Document.DeleteByQueryAsync(
      "nyc-open-data",
      "yellow-taxi",
      JObject.Parse(@"{
        ""query"": {
          ""term"": {
            ""capacity"": 7
          }
        }
      }"));
  Console.WriteLine($"Successfully deleted {ids.Count} documents");
} catch (KuzzleException e) {
  Console.Error.WriteLine(e);
}