MWriteAsync

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

  • check document validity
  • add kuzzle metadata
  • trigger realtime notifications (unless asked otherwise)

Arguments

Copied to clipboard!
public async Task<JObject> MWriteAsync(
    string index,
    string collection,
    JArray documents,
    bool waitForRefresh = false,
    bool notify = false);
Argument Type Description
index
string
Index name
collection
string
Collection name
documents
JArray
An array of JObject. Each JObject describes a document to create or replace, by exposing the following properties: _id, body

Options

Property Type Description
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

A JObject containing a hits array which represent the list of created documents, in the same order than the one provided in the query.

Property Type Description
_id
string
Created document unique identifier.
_source
JObject
Document content.
_version
int
Version number of the document
created
bool
A boolean telling whether a document is created

Usage

Copied to clipboard!
try {
  JObject response = await kuzzle.Bulk.MWriteAsync(
    "nyc-open-data",
    "yellow-taxi",
    JArray.Parse("[{_id: 'foo', body: {}}]"));
  Console.WriteLine(response.ToString(Formatting.None));
  /*
  {
    "hits": [
      {
      "_id": "foo",
      "_source": {},
      "_index": "nyc-open-data",
      "_type": "yellow-taxi",
      "_version": 1,
      "result": "created",
      "_shards": {
        "total": 2,
        "successful": 1,
        "failed": 0
      },
      "created": true,
      "status": 201
      }
    ],
    "total": 1
  }
  */
} catch (KuzzleException e) {
  Console.WriteLine(e);
}