Create a collection #
Creates a new collection.
Examples #
The following request creates a new collection called my-collection
in the
namespace my-namespace
:
PUT /my-namespace:my-collection
If creating a collection within the default namespace, it can be simplified as:
PUT /my-collection
Request #
PUT /[<namespace>:]<name>
Path parameters #
<namespace>
(Optional, string) The namespace which the collection belongs to. Namespace names must meet the following criteria:- Lowercase only
- Cannot include
\
/
,*
,?
,"
,<
,>
,|
,,
,
,#
- Cannot start with
-
,_
,+
- Cannot be
.
or..
- Cannot be longer than 255 bytes (note it is bytes, so multi-byte characters will count towards the 255 limit faster)
<name>
(Required, string) Name of the collection you wish to create. Collection names must meet the same criteria as namespace names.
Request body #
settings
Collection settingscollection.partitions_sharding_strategy
(Optional, object) Specifies the initial number of primary shards and how partitions are assigned to them for every rollings in this collection.By default, only 1 shard will be created, all the partitions will be assigned to it.
Supported strategies are listed below:
Hash
"hash": { "number_of_shards": <num_shards> }
One can specify the total number of shards, partitions are assigned to shards in this way:
shard_index = hash(partition_id) mod number_of_shards
Range
"range": ["0..128, 129..255"]
An array of partition range needs to be provided, every array item represents a shard, the partitions specified in it will be assigned to the shard.
The above example evenly assigns 256 partitions to 2 shards.
collection.partitions_sharding_strategy
(Optional, Integer) The number of replicas each primary shard has. Defaults to 1.