SDK
SDK C# v2.x
2

MGetAsync #

Gets multiple documents.

Arguments #

public async Task<JArray> MGetAsync(
  string index, 
  string collection, 
  JArray ids);

ArgumentTypeDescription
index
string
Index name
collection
string
Collection name
ids
JArray
Document IDs

Return #

Returns a JObject containing 2 arrays: successes and errors

The successes array contain the list of retrieved documents.

Each document have with following properties:

NameTypeDescription
_id
String
Document ID
_version
int
Version of the document in the persistent data storage
_source
JObject
Document content

The errors array contain the IDs of not found documents.

Exceptions #

Throws a KuzzleException if there is an error. See how to handle errors.

Usage #

try {
  JObject response = await kuzzle.Document.MGetAsync(
    "nyc-open-data",
    "yellow-taxi",
    JArray.Parse(@"[""some-id"", ""some-other-id""]"));
  Console.WriteLine(response.ToString());
  /*
  {
    "successes": [
      {
        "_id":"some-id",
        "_source":{
          "_kuzzle_info":{
            "active":true,
            "author":"-1",
            "updater":null,
            "updatedAt":null
          },
          "capacity":4
        },
        "_version":1
      },
      {
        "_id":"some-other-id",
        "_source":{
          "_kuzzle_info":{
            "active":true,
            "author":"-1",
            "updater":null,
            "updatedAt":null
          },
          "capacity":"7"
        },
        "_version":1
      }
    ],
    "errors": []
  }
  */
  Console.WriteLine($"Successfully retrieved {((JArray)response["successes"]).Count} documents");
} catch (KuzzleException e) {
  Console.Error.WriteLine(e);
}