code | type | title | description |
---|---|---|---|
true |
page |
CreateOrReplaceAsync |
Creates or replaces a document. |
Creates a new document in the persistent data storage, or replaces its content if it already exists.
public async Task<JObject> CreateOrReplaceAsync(
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 |
content |
JObject |
JObject representing the body of the document |
waitForRefresh |
bool ( false ) |
If true , waits for the change to be reflected for search (up to 1s) |
A JObject 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 created document |
result |
string |
Set to created or replaced . |
Throws a KuzzleException
if there is an error. See how to handle errors.
<<< ./snippets/create-or-replace.cs