Deleting Vectors
1. Deleting Vectors by ID
Example: Delete by IDs
index.delete(ids=["doc1", "doc2"], namespace="docs")
| Param | Description |
ids | List of IDs to delete (up to 1000) |
namespace | Target namespace (default "") |
filter | Metadata filter (pod only) |
delete_all | Wipe namespace |
Example: Delete by Filter
index.delete(filter={"source": {"$eq": "archive"}}, namespace="docs")
Warning: Filter-based delete is supported on pod indexes only. For serverless, query+collect IDs, then delete by ID.
3. Deleting All Vectors in Namespace
Example: Wipe Namespace
index.delete(delete_all=True, namespace="temp")
| Effect | Detail |
| Removes all vectors | Namespace remains (empty) |
| Irreversible | No undo |
4. Deleting Entire Namespace
Example: Delete Namespace
index.delete_namespace("temp") # serverless v5+
| Method | Behavior |
delete_namespace | Removes namespace entirely (serverless) |
delete(delete_all=True) | Empties namespace |
5. Batch Deleting Vectors
Example: Chunked Delete
for i in range(0, len(ids), 1000):
index.delete(ids=ids[i:i+1000])
6. Verifying Deletion Success
Example: Verify
index.delete(ids=["d1"])
res = index.fetch(ids=["d1"])
assert "d1" not in res["vectors"]
Note: Deletes are eventually consistent. Wait briefly before verifying or use stats.
7. Handling Delete Failures
| Error | Action |
| 404 Index missing | Confirm index name |
| 400 Empty IDs | Add at least one ID or use delete_all |
| 429 | Backoff and retry |
8. Implementing Soft Deletes
index.update(id="d1", set_metadata={"deleted": True})
# Filter out at query time:
res = index.query(vector=qv, top_k=10, filter={"deleted": {"$ne": True}})
| Approach | Tradeoff |
| Soft delete | Recoverable, but still stored/billed |
| Hard delete | Immediate cost reduction, irreversible |
9. Scheduling Automated Deletions
Example: TTL Job (Python)
# Cron: nightly
cutoff = int(time.time()) - 30 * 86400
# Query stale, collect IDs, delete in batches
stale = index.query(vector=[0]*1536, top_k=10000,
filter={"ts": {"$lt": cutoff}})
ids = [m["id"] for m in stale["matches"]]
index.delete(ids=ids)
| Operation | Speed |
| Delete by ID (1000) | ~50–200 ms |
| Delete by filter | O(matches); slower |
delete_all | Near-instant |
| Eventual consistency | 1–2 s typical |