vector
embedding.update
Replace the embedding for one vector, keeping its metadata.
strata vector update-embeddingdb.vectors.update_embedding(collection: 'str', key: 'str', vector: 'Optional[Sequence[float]]' = None, *, text: 'Optional[str]' = None) -> 'Any'wire vector_update_embedding
Replaces one visible vector's embedding and leaves its metadata as it stands - the mirror of `vector update-metadata`, which patches metadata and leaves the embedding. Use this to re-embed a document after a model change, a re-chunk or a backfill; `vector upsert` writes the whole record, so metadata not restated there is removed. Missing vectors return a no-op mutation acknowledgement and are never created. With `text` instead of a vector, the text is embedded through the collection's recorded model on the same inference path as `vector upsert`, so the `inference.*` failures listed below apply only to that form.
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 update-embedding --helphelp(db.vectors.update_embedding)
Example
Re-embed a vector without restating its 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 '{"lang":"en","tier":1}'created a in docsstrata vector update-embedding docs a '[0.0,1.0,0.0]'updated a in docsstrata vector query docs '[0.0,1.0,0.0]' --k 1KEY SCORE METADATAa 1.0 {"lang":"en","tier":1}
_ = db.vectors.create_collection("docs", 3, metric="cosine")_ = db.vectors.upsert("docs", "a", [1.0, 0.0, 0.0], metadata={"tag": "x"})_ = db.vectors.update_embedding("docs", "a", [0.0, 1.0, 0.0])db.vectors.get("docs", "a").data.metadata
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. |
| 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. 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, on the same terms as `VectorUpsert`: a vector carries no model, so supplying one is the caller's statement that the collection's recorded model produced it. |
Returns
MutationAck
- dataobject
- typestring
Errors
Recover by code. Retry policy and commit outcome come from the shipped error registry.