Skip to main content

Delete by predicate

Delete every entry that matches a metadata condition.

Every operation works on both Vector DB stores (you supply raw vectors) and AI stores (you supply text or images and Ahnlich AI generates the embeddings for you). Use the Vector DB / AI switch in the sample below.

Parameters

ParameterTypeDescription
storestringName of the store to delete from.
conditionpredicateA metadata predicate identifying the entries to remove.
schemastring · optionalSchema to target. Defaults to public.

All requests accept an optional schema field. When omitted, the server uses the public schema.

Behavior

  • Deletes all entries satisfying the predicate in one call.
  • Use a narrow predicate — there is no automatic confirmation step.

Sample query

Python
import asyncio
from grpclib.client import Channel
from ahnlich_client_py.grpc.services.db_service import DbServiceStub
from ahnlich_client_py.grpc.db import query as db_query
from ahnlich_client_py.grpc import predicates, metadata
from ahnlich_client_py.grpc.db.server import Del




async def delete_predicate():
async with Channel(host="127.0.0.1", port=1369) as channel:
client = DbServiceStub(channel)

condition = predicates.PredicateCondition(
value=predicates.Predicate(
equals=predicates.Equals(
key="label",
value=metadata.MetadataValue(raw_string="sorcerer")
)
)
)

response = await client.del_pred(
db_query.DelPred(
store="my_store",
schema="analytics",
condition=condition
)
)
# response.deleted_count shows how many items were deleted
if __name__ == "__main__":
asyncio.run(delete_predicate())

Response

The number of entries deleted.