SDK
SDK C# v1.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

WriteAsync #

Create or replace a document directly into the storage engine.

Arguments #

public async Task<JObject> WriteAsync(
    string index,
    string collection,
    JObject content,
    string documentId = null,
    bool waitForRefresh = false,
    bool notify = false);
ArgumentTypeDescription
index
string
Index name
collection
string
Collection name
content
JObject
Document content to create.

Options #

PropertyTypeDescription
documentId
string

(null)
set the document unique ID to the provided value, instead of auto-generating a random ID
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 #

Return a JObject with the following properties:

PropertyTypeDescription
_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 #

try {
  JObject content = JObject.Parse(@"{
    _kuzzle_info: {
      author: '<kuid>',
      createdAt: 1481816934209,
      updatedAt: null,
      updater: null,
      active: true,
      deletedAt: null
    }
  }");
  JObject response = await kuzzle.Bulk.WriteAsync(
    "nyc-open-data",
    "yellow-taxi",
    content);
  Console.WriteLine(response.ToString(Formatting.None));
  /*
  {
    "_index": "nyc-open-data",
    "_type": "yellow-taxi",
    "_id": "AWxHzUJ4wXgLgoMjxZ3S",
    "_version": 1,
    "result": "created",
    "_shards": {
      "total": 2,
      "successful": 1,
      "failed": 0
    },
    "created": true,
    "_source": {
      "kuzzle_info": {
      "author": "<kuid>",
      "createdAt": 1481816934209,
      "updatedAt": null,
      "updater": null,
      "active": true,
      "deletedAt": null
      }
    }
  }
  */
} catch (KuzzleException e) {
  Console.WriteLine(e);
}