MReplace #
Replaces multiple documents.
Returns a partial error (error code 206) if one or more documents can not be replaced.
Arguments #
MReplace(
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) |
Return #
Returns a json.RawMessage containing two arrays, successes and errors.
Each replaced document is an object of the successes
array with the following properties:
Name | Type | Description |
---|---|---|
_id | string | Document ID |
_version | int | Version of the document in the persistent data storage |
_source | json.RawMessage | Document content |
Each errored document is an object of the errors
array with the following properties:
Name | Type | Description |
---|---|---|
document | json.RawMessage | Document that caused the error |
status | int | HTTP error status |
reason | string | Human readable reason |
Usage #
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);
response, err := kuzzle.Document.MReplace(
"nyc-open-data",
"yellow-taxi",
json.RawMessage(`[
{
"_id": "some-id",
"body": { "capacity": 4 }
},
{
"_id": "some-other-id",
"body": { "capacity": 4 }
}
]`),
nil)
if err != nil {
log.Fatal(err)
} else {
fmt.Println(string(response))
fmt.Println("Success")
}
Edit this page on Github(opens new window)