delete - Delete data
delete() is used to delete records from a collection. You can delete records by ID, metadata filter, or document filter.
This API is only available when you are connected to the database 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 Quick Start.
-
You are connected to the database. For more information about how to connect to the database, see Client.
-
If you are using seekdb or OceanBase Database in client mode, make sure that the user to whom you are connected has the
DELETEprivilege 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
Upsert(
ids=ids,
embeddings=embeddings,
documents=documents,
metadatas=metadatas
)
| Parameter | Type | Required | Description | Example value |
|---|---|---|---|---|
ids | string or List[str] | Optional | The ID of the record to be deleted. You can specify a single ID or an array of IDs. | item1 |
where | dict | Optional | The metadata filter. | {"category": {"$eq": "AI"}} |
where_document | dict | Optional | The document filter. | {"$contains": "obsolete"} |
At least one of the id, where, or where_document parameters must be specified.
Request examples
import pyseekdb
# Create a client
client = pyseekdb.Client()
collection = client.get_collection("my_collection")
# Delete by IDs
collection.delete(ids=["item1", "item2", "item3"])
# Delete by single ID
collection.delete(ids="item1")
# Delete by metadata filter
collection.delete(where={"category": {"$eq": "AI"}})
# Delete by comparison operator
collection.delete(where={"score": {"$lt": 50}})
# Delete by document filter
collection.delete(where_document={"$contains": "obsolete"})
# Delete with combined filters
collection.delete(
where={"category": {"$eq": "AI"}},
where_document={"$contains": "deprecated"}
)
Response parameters
None