Core
API v2.x
2

create #

Creates a new collection, in the provided index.

Collection names must meet the following criteria:

  • Lowercase only
  • Cannot include one of the following characters: \\, /, *, ?, ", <, >, |, (space character), ,, #, :, %, &, .
  • Cannot be longer than 126 bytes (note it is bytes, so multi-byte characters will count towards the 126 limit faster)

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.

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.

Available since 2.1.0

You can also provide Elasticsearch index settings when creating a new collection.


Query Syntax #

HTTP #

Copied to clipboard!
URL: http://kuzzle:7512/<index>/<collection>
Method: PUT
Body:
Available since 2.1.0
Copied to clipboard!
{
  "mappings": {
    "dynamic": "[true|false|strict]", // boolean are also accepted
    "_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"
      }
    }
  },
  "settings": {
    "analysis" : {
      "analyzer":{
        "content":{
          "type":"custom",
          "tokenizer":"whitespace"
        }
      }
    }
  }
}
Deprecated since 2.1.0
Copied to clipboard!
{
  "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 #

Available since 2.1.0
Copied to clipboard!
{
  "index": "<index>",
  "collection": "<collection>",
  "controller": "collection",
  "action": "create",
  "body": {
    "mappings": {
      "dynamic": "[true|false|strict]", // boolean are also accepted
      "_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"
        }
      }
    },
    "settings": {
      "analysis" : {
        "analyzer":{
          "content":{
            "type":"custom",
            "tokenizer":"whitespace"
          }
        }
      }
    }
  }
}
Deprecated since 2.1.0
Copied to clipboard!
{
  "index": "<index>",
  "collection": "<collection>",
  "controller": "collection",
  "action": "create",
  "body": {
    "dynamic": "[true|false|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 create
  • index: index name

Body properties #

Optional: #

Available since 2.1.0
Deprecated since 2.1.0

Response #

Returns a confirmation that the collection is being created:

Copied to clipboard!
{
  "status": 200,
  "error": null,
  "index": "<index>",
  "collection": "<collection>",
  "controller": "collection",
  "action": "create",
  "requestId": "<unique request identifier>",
  "result": {
    "acknowledged": true
  }
}

Possible errors #