vector
upsert
Insert or replace one vector.
strata vector upsertdb.vectors.upsert(collection: 'str', key: 'str', vector: 'Sequence[float]', *, 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.
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 cosinestrata vector upsert docs a [1.0,0.0,0.0] --metadata {"tag":"x"}strata vector exists docs a
_ = 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. |
| vector | array | yes | Dense embedding. Accepted at wire (f64) precision and narrowed to the stored f32; a value that underflows or overflows f32 is rejected. |
| 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"`. |
Returns
MutationAck<VectorWrite>
- dataobject
- 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.vector_embedding | never | not_started |
| invalid_argument.engine.vector_metadata | never | not_started |
| invalid_argument.executor.vector_dimension | never | not_started |