Updating Data

Every write to an Edge Shard goes through a single method, update, which takes one UpdateOperation describing what to change. The operation is written to the write-ahead log before it is applied to storage, so an update that has returned survives a crash.

update

def update(self, operation: UpdateOperation) -> None
pub fn update(&self, operation: UpdateOperation) -> OperationResult<()>
ParameterDescription
operationThe operation to apply.

Returns nothing in Python. In Rust, returns Ok(()) on success.

Creating a named vector that already exists with different parameters fails.

Update Operations

In Python, UpdateOperation is a class with static constructors, one per operation. Each returns an UpdateOperation to pass to update.

OperationParametersDescription
upsert_pointspoints, condition, update_modeInsert or update points.
delete_pointspoint_idsDelete points by ID.
delete_points_by_filterfilterDelete every point matching a filter.
update_vectorspoint_vectors, conditionReplace vectors on existing points.
delete_vectorspoint_ids, vector_namesDelete named vectors from points.
delete_vectors_by_filterfilter, vector_namesDelete named vectors from matching points.
set_payloadpoint_ids, payload, keyMerge payload fields into points.
set_payload_by_filterfilter, payload, keyMerge payload fields into matching points.
overwrite_payloadpoint_ids, payload, keyReplace the entire payload on points.
overwrite_payload_by_filterfilter, payload, keyReplace the entire payload on matching points.
delete_payloadpoint_ids, keysDelete named payload fields from points.
delete_payload_by_filterfilter, keysDelete named payload fields from matching points.
clear_payloadpoint_idsDelete all payload from points.
clear_payload_by_filterfilterDelete all payload from matching points.

Payload Indexes

The update operation also enables you to create and delete payload indexes.

OperationParametersDescription
create_field_indexfield_name, schemaIndex a payload field.
delete_field_indexfield_nameRemove a payload field index.

Modify the Vector Schema

Add or remove named vectors to an existing Edge Shard’s schema. This is useful when migrating to a new embedding model or adding hybrid search to an Edge Shard that already contains data.

OperationParametersDescription
create_dense_vectorvector_name, size, distance, multivector_config, datatypeAdd a dense named vector to the schema.
create_sparse_vectorvector_name, modifier, datatypeAdd a sparse named vector to the schema.
delete_vector_namevector_nameRemove a named vector from the schema.

Parameters

The key parameter on the payload operations targets a nested field path rather than the payload root.

The condition parameter gates the write by a filter, but the two operations differ. On update_vectors it applies to the whole operation: only points matching the filter are updated. On upsert_points it applies only to points that already exist, so an existing point that fails the filter is left untouched while a point that is new to the shard is inserted regardless of the filter.

The condition parameter controls whether a write is applied, but its behavior depends on the operation. For update_vectors, only points that match the filter are updated. For upsert_points, the filter applies only to existing points. Existing points that do not match the filter remain unchanged, while new points are inserted regardless of the filter.

upsert_points also takes an update_mode:

ModeBehavior
UpdateMode.UpsertInsert new points and update existing ones. This is the default behavior.
UpdateMode.InsertOnlyInsert new points, leave existing ones untouched.
UpdateMode.UpdateOnlyUpdate existing points, do not insert new ones.

In Rust, UpdateOperation is an enum that groups operations by what they modify:

VariantCovers
PointOperationUpserting, deleting, and syncing points.
VectorOperationUpdating and deleting named vectors on existing points.
PayloadOperationSetting, overwriting, deleting, and clearing payload.
FieldIndexOperationCreating and deleting payload field indexes.
VectorNameOperationAdding and removing named vectors from the schema.
Was this page useful?

Thank you for your feedback! 🙏

We are sorry to hear that. 😔 You can edit this page on GitHub, or create a GitHub issue.