This page shows you how to use the delete endpoint to remove records from an index namespace.

Delete records by ID

Since Pinecone records can always be efficiently accessed using their ID, deleting by ID is the most efficient way to remove specific records.

To remove records from the default "" namespace, don’t specify a namespace in your request.

# pip install "pinecone[grpc]"
from pinecone.grpc import PineconeGRPC as Pinecone

pc = Pinecone(api_key="YOUR_API_KEY")

# To get the unique host for an index, 
# see https://docs.pinecone.io/guides/data/target-an-index
index = pc.Index(host="INDEX_HOST")

index.delete(ids=["id-1", "id-2"], namespace='example-namespace')

Delete records by metadata

Serverless indexes do not support deleting by metadata. You can delete records by ID prefix instead.

Delete an entire namespace

In serverless indexes, it’s safe to delete an entire namespace or a large number of records at once because reads and writes do not share compute resources.

To delete an entire namespace and all of its records, provide a namespace parameter and specify the appropriate deleteAll parameter for your SDK. To target the default namespace, set namespace to "".

# pip install "pinecone[grpc]"
from pinecone.grpc import PineconeGRPC as Pinecone

pc = Pinecone(api_key="YOUR_API_KEY")

# To get the unique host for an index, 
# see https://docs.pinecone.io/guides/data/target-an-index
index = pc.Index(host="INDEX_HOST")

index.delete(delete_all=True, namespace='example-namespace')

Delete an entire index

To remove all records from an index, delete the index and recreate it.

Data freshness

Pinecone is eventually consistent, so there can be a slight delay before new or changed records are visible to queries. You can view index stats to check data freshness.