Skip to content

Latest commit

 

History

History
58 lines (42 loc) · 1.66 KB

File metadata and controls

58 lines (42 loc) · 1.66 KB
code type title description
true
page
CreateAsync
Create a new collection.

CreateAsync

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.

Arguments

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

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.

Exceptions

Throws a KuzzleException if there is an error. See how to handle error.

Usage

<<< ./snippets/create.cs