SDK
SDK C# v2.x
2

MWriteAsync #

This is a low level route intended to bypass Kuzzle actions on document creation, notably:

Arguments #

public async Task<JObject> MWriteAsync(
    string index,
    string collection,
    JArray documents,
    bool waitForRefresh = false,
    bool notify = false);
ArgumentTypeDescription
index
string
Index name
collection
string
Collection name
documents
JArray
An array of JObject representing the documents

documents #

An array of JObject. Each object describes a document to create or replace, by exposing the following properties:

  • _id: document unique identifier (optional)
  • body: document content

Options #

PropertyTypeDescription
waitForRefresh
bool

(false)
If set to true, Kuzzle will not respond until the created/replaced documents are indexed
notify
bool

(false)
If set to true, Kuzzle will trigger realtime notifications

Return #

Returns a JObject containing 2 arrays: successes and errors

Each created or replaced document is an object of the successes array with the following properties:

NameTypeDescription
_id
String
Document ID
_version
int
Version of the document in the persistent data storage
_source
JObject
Document content
created
bool
True if the document was created

Each errored document is an object of the errors array with the following properties:

NameTypeDescription
document
JObject
Document that cause the error
status
int
HTTP error status
reason
String
Human readable reason

Usage #

try {
  JObject response = await kuzzle.Bulk.MWriteAsync(
    "nyc-open-data",
    "yellow-taxi",
    JArray.Parse("[{_id: 'foo', body: {}}]"));
  Console.WriteLine(response.ToString(Formatting.None));
  /*
  {
    errors: [],
    successes: [
      {
        _id: "foo",
        _version: 1,
        _source: {},
        created: true
      }
    ]
  }
  */
} catch (KuzzleException e) {
  Console.WriteLine(e);
}