code | type | title | description |
---|---|---|---|
true |
page |
CreateAsync |
Create a new collection. |
Creates a new collection in the provided index
.
You can also provide an optional body with a collection mapping allowing you to exploit the full capabilities of our persistent data storage layer.
This method will only update the mapping if the collection already exists.
public async Task CreateAsync(
string index,
string collection,
JObject mappings = null);
Argument | Type | Description |
---|---|---|
index |
string |
Index name |
collection |
string |
Collection name |
mapping |
JObject ( null ) |
JObject representing the collection data mapping |
A JObject representing the collection data mapping.
The mapping must have a root field properties
containing the mapping definition:
{
"properties": {
"field1": { "type": "text" },
"field2": {
"properties": {
"nestedField": { "type": "keyword" }
}
}
}
}
More information about database mappings here.
Throws a KuzzleException
if there is an error. See how to handle error.
<<< ./snippets/create.cs