create #
Creates a new collection, in the provided index
.
Available since 1.3.0
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 when the collection already exists.
Available since 1.7.1
You can define the collection dynamic mapping policy by setting the dynamic
field to the desired value.
You can define collection additional metadata within the _meta
root field.
Query Syntax #
HTTP #
URL: http://kuzzle:7512/<index>/<collection>
Method: PUT
Body:
{
"dynamic": "[false|true|strict]",
"_meta": {
"field": "value"
},
"properties": {
"field1": {
"type": "integer"
},
"field2": {
"type": "keyword"
},
"field3": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
}
}
}
Other protocols #
{
"index": "<index>",
"collection": "<collection>",
"controller": "collection",
"action": "create",
"body": {
"dynamic": "[false|true|strict]",
"_meta": {
"field": "value"
},
"properties": {
"field1": {
"type": "integer"
},
"field2": {
"type": "keyword"
},
"field3": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
}
}
}
}
Arguments #
collection
: name of the collection to createindex
: index name
Body properties #
Optional: #
dynamic
: dynamic mapping policy for new fields. Allowed values:true
(default),false
,strict
_meta
: collection additional metadata stored next to the collectionproperties
: object describing the data mapping to associate to the new collection, using Elasticsearch types definitions format
Response #
Returns a confirmation that the collection is being created:
{
"status": 200,
"error": null,
"index": "<index>",
"collection": "<collection>",
"controller": "collection",
"action": "create",
"requestId": "<unique request identifier>",
"result": {
"acknowledged": true
}
}
Possible errors #
Edit this page on Github(opens new window)