Skip to main content

update - Update data

The update() method is used to update existing records in a collection. The record must exist, otherwise an error will be raised.

info

This API is only available when using a Client. For more information about the Client, see Client.

Prerequisites

  • You have installed pyseekdb. For more information about how to install pyseekdb, see Get Started.

  • You have connected to the database. For more information about how to connect, see Client.

  • If you are using seekdb in client mode or OceanBase Database, make sure that the user to which you have connected has the UPDATE privilege on the table to be operated. For more information about how to view the privileges of the current user, see View User Privileges. If you do not have this privilege, contact the administrator to grant it to you. For more information about how to directly grant privileges, see Directly Grant Privileges.

Request parameters

update(
ids=ids,
embeddings=embeddings,
documents=documents,
metadatas=metadatas
)
ParameterTypeRequiredDescriptionExample value
idsstring or List[str]YesThe ID to be modified. It can be a single ID or an array of IDs.item1
embeddingsList[float] or List[List[float]]NoThe new vectors. If provided, they will be used directly (ignoring embedding_function). If not provided, you can provide documents to automatically generate vectors.[[0.9, 0.8, 0.7], [0.6, 0.5, 0.4]]
documentsstring or List[str]NoThe new documents. If vectors are not provided, documents will be converted to vectors using the collection's embedding_function."New document text"
metadatasdict or List[dict]NoThe new metadata.{"category": "AI"}
info

You can update only the metadatas. The embedding_function used must be associated with the collection.

Request example

import pyseekdb

# Create a client
client = pyseekdb.Client()

collection = client.get_collection("my_collection")
collection1 = client.get_collection("my_collection1")

# Update single item
collection.update(
ids="item1",
metadatas={"category": "AI", "score": 98} # Update metadata only
)

# Update multiple items
collection.update(
ids=["item1", "item2"],
embeddings=[[0.9, 0.8, 0.7], [0.6, 0.5, 0.4]], # Update embeddings
documents=["Updated document 1", "Updated document 2"] # Update documents
)

# Update with documents only - embeddings auto-generated by embedding_function
# Requires: collection must have embedding_function set
collection1.update(
ids="doc1",
documents="New document text", # Embeddings will be auto-generated
metadatas={"category": "AI"}
)

Response parameters

None

References