SDK
SDK Golang v1.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

MUpdate #

Updates multiple documents.

Returns a partial error (error code 206) if one or more documents can not be updated.

Conflicts may occur if the same document gets updated multiple times within a short timespan in a database cluster.

You can set the retryOnConflict optional argument (with a retry count), to tell Kuzzle to retry the failing updates the specified amount of times before rejecting the request with an error.

Arguments #

Copied to clipboard!
MUpdate(
    index string,
    collection string,
    documents json.RawMessage,
    options types.QueryOptions) (json.RawMessage, error)

Argument Type Description
index
string
Index name
collection
string
Collection name
documents
json.RawMessage
Document contents to update
options
types.QueryOptions
A struct containing 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
string

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

(0)
Number of times the database layer should retry in case of version conflict

Return #

Returns a json.RawMessage containing the update documetns.

Usage #

Copied to clipboard!
kuzzle.Document.Create(
  "nyc-open-data",
  "yellow-taxi",
  "some-id",
  json.RawMessage(`{"capacity": 4}`),
  nil);
kuzzle.Document.Create(
  "nyc-open-data",
  "yellow-taxi",
  "some-other-id",
  json.RawMessage(`{"capacity": 7}`),
  nil);
response, err := kuzzle.Document.MReplace(
  "nyc-open-data",
  "yellow-taxi",
  json.RawMessage(`[
    {
      "_id": "some-id",
      "body": { "category": "sedan" }
    },
    {
      "_id": "some-other-id",
      "body": { "category": "limousine" }
    }
  ]`),
  nil)
if err != nil {
  log.Fatal(err)
} else {
  fmt.Println(string(response))
  fmt.Println("Success")
}