Skip to main content
Adds vectors to the index, or replaces existing vectors with the same ID. Upsert takes either VectorItems (sent as JSON) or BinaryUpsertParams (sent as binary); UpsertVectors is a shortcut for the binary form.

Parameters

VectorItems

VectorItems is a []VectorItem:

BinaryUpsertParams

Vectors are sent as base64-encoded little-endian float32, which is faster for large batches. UpsertVectors(ctx, ids, vectors, metadata) is the same as Upsert with a BinaryUpsertParams that has no contents.
Store dates in Metadata as epoch milliseconds (t.UnixMilli()) so range filters work on them. See Dates.
Don’t upsert vectors containing NaN or infinite values. The service stores them, and later get or query calls on that index that return vectors or distances fail with a 5xx error. The SDK doesn’t check for them.

Returns

error only; nil on success.

Errors

  • Wraps a sentinel. A BinaryUpsertParams field is empty, slices differ in length (ErrIDsVectorsLengthMismatch, ErrMetadataLengthMismatch, ErrContentsLengthMismatch), or vectors differ in length (ErrInconsistentDimension). Returned before any request is sent. VectorItems aren’t checked in the SDK.
  • The service rejects the items (HTTP 400), for example a vector with the wrong dimension.
The apiKey is invalid, or a read-only user key is used (HTTP 401/403).
The service returns 5xx or can’t be reached.
See Errors.

Example Usage

VectorItems

BinaryUpsertParams with metadata and contents

Set contents on a VectorItem

On an index with an embedding model, leave Vector empty and the service embeds the contents.

UpsertVectors

Replace an existing item