Delete data

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

Delete specific 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.

ℹ️

Note

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

from pinecone import Pinecone

pc = Pinecone(api_key="YOUR_API_KEY")
index = pc.Index("pinecone-index")

index.delete(ids=["id-1", "id-2"], namespace='example-namespace')
import { Pinecone } from '@pinecone-database/pinecone'

const pc = new Pinecone({ apiKey: "YOUR_API_KEY" })
const index = pc.index("pinecone-index")

const ns = index.namespace('example-namespace')
// Delete one record by ID.
await ns.deleteOne('id-1');
// Delete more than one record by ID.
await ns.deleteMany(['id-2', 'id-3']);
# The `POST` request below uses the unique endpoint for an index.
# See https://docs.pinecone.io/docs/get-index-endpoint for details.
PINECONE_API_KEY="YOUR_API_KEY"
INDEX_HOST="INDEX_HOST"

curl -X POST "https://$INDEX_HOST/vectors/delete" \
  -H "Api-Key: $PINECONE_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "ids": [
      "id-1", 
      "id-2"
    ],
    "namespace": "example-namespace"
  }
'

Delete specific records by metadata

For pod-based indexes, you can delete records by metadata by passing a metadata filter expression to the delete operation.

For serverless indexes, however, it is not possible to delete by metadata. Instead, you can delete records by ID prefix.

Delete all records from a namespace

To delete all records from a namespace, specify the appropriate deleteAll parameter for your client and provide a namespace parameter.

ℹ️

Note

Deleting all records from a namespace also deletes the namespace itself.

from pinecone import Pinecone

pc = Pinecone(api_key="YOUR_API_KEY")
index = pc.Index("pinecone-index")

index.delete(delete_all=True, namespace='example-namespace')
import { Pinecone } from '@pinecone-database/pinecone'

const pc = new Pinecone({ apiKey: "YOUR_API_KEY" })
const index = pc.index("pinecone-index")

await index.namespace('example-namespace').deleteAll();
# The `POST` request below uses the unique endpoint for an index.
# See https://docs.pinecone.io/docs/get-index-endpoint for details.
PINECONE_API_KEY="YOUR_API_KEY"
INDEX_HOST="INDEX_HOST"

curl -X POST "https://$INDEX_HOST/vectors/delete" \
  -H "Api-Key: $PINECONE_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "deleteAll": true,
    "namespace": "example-namespace"
  }
'

Delete all records from an index

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