Collections

Create a collection

PUT
Creates a new collection with the given parameters.

Path parameters

collection_namestringRequired
Name of the new collection

Query parameters

timeoutintegerOptional
Wait for operation commit timeout in seconds. If timeout is reached - request will return with service error.

Request

This endpoint expects an object.
vectors
unionOptional
Vector params separator for single and multiple vector modes Single mode: { "size": 128, "distance": "Cosine" } or multiple mode: { "default": { "size": 128, "distance": "Cosine" } }
shard_number
integerOptional
For auto sharding: Number of shards in collection. - Default is 1 for standalone, otherwise equal to the number of nodes - Minimum is 1 For custom sharding: Number of shards in collection per shard group. - Default is 1, meaning that each shard key will be mapped to a single shard - Minimum is 1
sharding_method
unionOptional
Sharding method Default is Auto - points are distributed across all available shards Custom - points are distributed across shards according to shard key
replication_factor
integerOptional
Number of shards replicas. Default is 1 Minimum is 1
write_consistency_factor
integerOptional
Defines how many replicas should apply the operation for us to consider it successful. Increasing this number will make the collection more resilient to inconsistencies, but will also make it fail if not enough replicas are available. Does not have any performance impact.
on_disk_payload
booleanOptional
If true - point's payload will not be stored in memory. It will be read from the disk every time it is requested. This setting saves RAM by (slightly) increasing the response time. Note: those payload values that are involved in filtering and are indexed - remain in RAM.
hnsw_config
unionOptional
Custom params for HNSW index. If none - values from service configuration file are used.
wal_config
unionOptional
Custom params for WAL. If none - values from service configuration file are used.
optimizers_config
unionOptional
Custom params for Optimizers. If none - values from service configuration file are used.
init_from
unionOptional
Specify other collection to copy data from.
quantization_config
unionOptional
Quantization parameters. If none - quantization is disabled.
sparse_vectors
map from strings to optional objectsOptional
Sparse vector data config.

Response

This endpoint returns an object
time
doubleOptional
Time spent to process this request
status
stringOptional
result
booleanOptional
PUT
1# Minimal curl command to create a collection with a vector field
2
3curl -X PUT http://localhost:6333/collections/collection_name \
4 -H "api-key: <apiKey>" \
5 -H "Content-Type: application/json" \
6 -d '{
7 "vectors": {
8 "size": 300,
9 "distance": "Cosine"
10 }
11 }'
12
13# Or with a sparse vector field
14
15curl -X PUT http://localhost:6333/collections/collection_name \
16 -H "api-key: <apiKey>" \
17 -H "Content-Type: application/json" \
18 -d '{
19 "vectors": {
20 "size": 1536,
21 "distance": "Cosine"
22 },
23 "sparse_vectors": {
24 "splade-model-name": {
25 "index": {
26 "on_disk": true
27 }
28 }
29 }
30 }'
200Updated
1{
2 "time": 1.1,
3 "status": "status",
4 "result": true
5}