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);
Argument | Type | Description |
---|---|---|
index | string | Index name |
collection | string | Collection name |
content | JObject | Document content to create. |
Options #
Property | Type | Description |
---|---|---|
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:
Property | Type | Description |
---|---|---|
_id | string | Created document unique identifier. |
_source | JObject | Document content. |
_version | int | Version number of the document |
Usage #
try {
JObject content = JObject.Parse(@"{
_kuzzle_info: {
author: '<kuid>',
createdAt: 1481816934209,
updatedAt: null,
updater: null
}
}");
JObject response = await kuzzle.Bulk.WriteAsync(
"nyc-open-data",
"yellow-taxi",
content);
Console.WriteLine(response.ToString(Formatting.None));
/*
{
"_id": "AWxHzUJ4wXgLgoMjxZ3S",
"_version": 1,
"_source": {
"kuzzle_info": {
"author": "<kuid>",
"createdAt": 1481816934209,
"updatedAt": null,
"updater": null
}
}
}
*/
} catch (KuzzleException e) {
Console.WriteLine(e);
}
Edit this page on Github(opens new window)