MGet #
Gets multiple documents.
Returns a partial error (error code 206) if one or more document can not be retrieved.
Arguments #
MGet(
index string,
collection string,
ids []string,
options types.QueryOptions) (json.RawMessage, error)
Arguments | Type | Description |
---|---|---|
index | string | Index name |
collection | string | Collection name |
ids | []string | Document IDs |
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 |
Return #
Returns a json.RawMessage containing two arrays, successes and errors.
The successes
array contain the list of retrieved documents.
Each document have the 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 |
The errors
array contain the IDs of not found documents.
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)
ids := []string{"some-id", "some-other-id"}
response, err := kuzzle.Document.MGet("nyc-open-data", "yellow-taxi", ids, nil)
if err != nil {
log.Fatal(err)
} else {
fmt.Println(string(response))
fmt.Println("Success")
}
Edit this page on Github(opens new window)