vector
upsert
Insert or replace one vector.
strata vector upsertdb.vectors.upsert(collection: 'str', key: 'str', vector: 'Optional[Sequence[float]]' = None, *, text: 'Optional[str]' = None, metadata: 'Optional[dict]' = None) -> 'Any'wire vector_upsert
Upserts one vector key with a dense embedding and optional metadata. The vector dimension must match the collection configuration. With `text` instead of a vector, the text is embedded through the collection's recorded model on the same inference path as `inference.embed`, so the `inference.*` failures listed below apply only to that form; a supplied vector never reaches the inference runtime.
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 upsert --helphelp(db.vectors.upsert)
Example
Insert or replace a vector with optional metadata.
strata vector collection create docs 3 --metric cosinecreated collection docs (3 dimensions, cosine)strata vector upsert docs a '[1.0,0.0,0.0]' --metadata '{"tag":"x"}'created a in docsstrata vector exists docs atrue
_ = db.vectors.create_collection("docs", 3, metric="cosine")_ = db.vectors.upsert("docs", "a", [1.0, 0.0, 0.0], metadata={"tag": "x"})db.vectors.exists("docs", "a")
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| collection | string | yes | Collection name. |
| key | string | yes | Vector key. |
| branch | string or null | no | Target branch. Defaults to the executor handle branch. |
| metadata | any | no | Optional metadata. |
| space | string or null | no | Target product space. Defaults to `"default"`. |
| text | string or null | no | Text to embed with the collection's recorded model, instead of supplying a vector (D10). Exactly one of `vector` or `text`. |
| vector | array | no | Dense embedding. Accepted at wire (f64) precision and narrowed to the stored f32; a value that underflows or overflows f32 is rejected. Empty when `text` is supplied instead. A vector carries no model, so when the collection records an embedding model, Strata cannot check this vector against it: supplying one is the caller's statement that the recorded model produced it. Only `text` is embedded under the record. |
Returns
MutationAck
- dataobject
- typestring
Errors
Recover by code. Retry policy and commit outcome come from the shipped error registry.