ReplaceAsync #
Replaces the content of an existing document.
Arguments #
public async Task<JObject> ReplaceAsync(
string index, string collection, string id, JObject content, bool waitForRefresh = false );
Argument | Type | Description |
---|---|---|
index | string | Index name |
collection | string | Collection name |
id | string | Document ID |
document | JObject | JObject representing the document |
waitForRefresh | bool ( false ) | if true , Kuzzle will not respond until the newly replaced document is indexed |
Return #
A JObject representing an object containing the document creation result.
Property | Type | Description |
---|---|---|
_id | string | ID of the newly created document |
_version | int | Version of the document in the persistent data storage |
_source | JObject | JObject representing the replaced document |
result | string | Set to replaced in case of success |
Exceptions #
Throws a KuzzleException
if there is an error. See how to handle errors.
Usage #
try {
await kuzzle.Document.CreateAsync(
"nyc-open-data",
"yellow-taxi",
JObject.Parse(@"{""color"": ""yellow""}"),
id: "some-id");
JObject response = await kuzzle.Document.ReplaceAsync(
"nyc-open-data",
"yellow-taxi",
"some-id",
JObject.Parse(@"{
""capacity"": 4,
""category"": ""sedan""
}"));
Console.WriteLine(response.ToString());
/*
{
"_id": "some-id",
"_version": 2,
"_source": {
"capacity": 4,
"category": "sedan",
"_kuzzle_info": {
"author": "-1",
"createdAt": 1538641029988,
"updatedAt": 1538641029988,
"updater": "-1"
}
}
}
*/
Console.WriteLine("Document successfully replaced");
} catch (KuzzleException e) {
Console.Error.WriteLine(e);
}
Edit this page on Github(opens new window)