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.

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 );

ArgumentTypeDescription
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.

PropertyTypeDescription
_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());
  /*
  {
    "_index": "nyc-open-data",
    "_type": "yellow-taxi",
    "_id": "some-id",
    "_version": 2,
    "result": "updated",
    "_source": {
      "capacity": 4,
      "category": "sedan",
      "_kuzzle_info": {
        "author": "-1",
        "createdAt": 1538641029988,
        "updatedAt": 1538641029988,
        "updater": "-1",
        "active": true,
        "deletedAt": null
      }
    }
  }
  */
  Console.WriteLine("Document successfully replaced");
} catch (KuzzleException e) {
  Console.Error.WriteLine(e);
}