SDK
SDK Golang v3.x
2

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).

Arguments #

MDelete(  index string,  collection string,  ids []string,  options types.QueryOptions) ([]string, error)

ArgumentTypeDescription
index
string
Index name
collection
string
Collection name
ids
[]string
The ids of the documents to delete
options
types.QueryOptions
A struct containing query options

options #

Additional query options

OptionType
(default)
Description
Queuable
bool

(true)
If true, queues the request during downtime, until connected to Kuzzle again
Refresh
string

("")
If set to wait_for, waits for the change to be reflected for search (up to 1s)

Return #

Returns a json.RawMessage containing two arrays, successes and errors.

The successes array contain the successfuly deleted document IDs.

Each deletion error is an object of the errors array with the following properties:

NameTypeDescription
_id
string
Document ID
reason
string
Human readable reason

Usage #

ids := []string{"some-id", "some-other-id"} kuzzle.Document.Create(  "nyc-open-data",  "yellow-taxi",  "some-id",  json.RawMessage(`{}`),  nil) kuzzle.Document.Create(  "nyc-open-data",  "yellow-taxi",  "some-other-id",  json.RawMessage(`{}`),  nil) deletedJSON, err := kuzzle.Document.MDelete("nyc-open-data", "yellow-taxi", ids, nil) if err != nil {  log.Fatal(err) } else {  type deletedResult struct {  Successes []json.RawMessage `json:"successes"`  Errors []json.RawMessage `json:"errors"`  }  var deleted deletedResult  json.Unmarshal(deletedJSON, &deleted)  fmt.Printf("Successfully deleted %d documents", len(deleted.Successes)) }