SDK
SDK C# v2.x
2

DeleteByQueryAsync #

Deletes documents matching the provided search query.

Kuzzle uses the ElasticSearch Query DSL syntax.

Arguments #

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


Argument Type Description
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 #

Copied to clipboard!
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);
}