vector
collection.create
Create a vector collection with a dimension, metric, and optionally the model that produces its vectors.
strata vector collection createdb.vectors.create_collection(name: 'str', dimension: 'int', *, metric: 'str' = 'cosine', embedding_model: 'Optional[str]' = None) -> 'Any'wire vector_create_collection
Creates a collection for dense vectors. The dimension and metric become part of the collection contract for future upserts and queries. Passing `embedding_model` records which model produces the collection's vectors: it lets `text` be embedded for upserts and queries, and lets a query embedded with a different model be refused rather than silently compared. A collection created without one can declare it later with `vector.collection.set_embedding_model`.
Successful mutations return an acknowledgement of the outcome: for a state-changing write, the affected target with the mutation effect and commit facts; for mutations that produce a domain result (such as a branch or a promotion outcome), that result object.
To see the complete help for this command, run:
strata vector collection create --helphelp(db.vectors.create_collection)
Example
Create a vector collection, then confirm its dimension.
strata vector collection create docs 3 --metric cosinecreated collection docs (3 dimensions, cosine)strata vector collection stats docsNAME DIMENSION METRIC COUNT EMBEDDING_MODELdocs 3 cosine 0 -
_ = db.vectors.create_collection("docs", 3, metric="cosine")db.vectors.stats("docs").dimension
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| collection | string | yes | Collection name. |
| dimension | integer | yes | Embedding dimension. |
| metric | VectorDistanceMetric | yes | Distance metric.one of: cosine, euclidean, dot_product |
| branch | string or null | no | Target branch. Defaults to the executor handle branch. |
| embedding_model | string or null | no | The model that produces this collection's vectors (D9). What the record governs: `text` on `vector upsert` and `vector query` is embedded with this model and no other, so text writes and searches cannot mix models - the failure dimension cannot catch, since two models at the same width return neighbours that are ranked and meaningless. What it cannot govern: a `vector` supplied directly carries no model, so Strata cannot check one against the record; supplying a vector is the caller's statement that this model produced it. |
| space | string or null | no | Target product space. Defaults to `"default"`. |
Returns
MutationAck
- dataobject
Shared pagination continuation facts.
- typestring
Errors
Recover by code. Retry policy and commit outcome come from the shipped error registry.
| Code | Retry | Commit outcome |
|---|---|---|
| failed_precondition.engine.runtime_closed | never | not_started |
| not_found.engine.branch | never | not_applicable |
| invalid_argument.engine.product_space | never | not_started |
| invalid_argument.engine.vector_collection | never | not_started |
| invalid_argument.engine.vector_key | never | not_started |
| not_found.engine.vector_collection | never | not_applicable |
| invalid_argument.engine.vector_dimension | never | not_started |
| invalid_argument.engine.embedding_model | never | not_started |
| invalid_argument.executor.vector_dimension | never | not_started |