Manage data

In addition to inserting and querying data, there are other ways you can interact with vector data in a Pinecone index. This section walks through the various vector operations available.

Video overview

Connect to an index

If you're using a Pinecone client library to access an index, you'll need to open a session with the index:

# Connect to the index
index = pinecone.Index("pinecone-index")
# Not applicable

Pinecone indexes each have their own DNS endpoint.

Describe index statistics

Get statistics about an index, such as vector count per namespace:

curl -i -X GET \
  -H 'Api-Key: YOUR_API_KEY'

Fetching vectors

The Fetch operation looks up and returns vectors, by id, from an index. The returned vectors include the vector data and/or metadata.

Fetch items by their ids:

index.fetch(ids=["id-1", "id-2"])

# Returns:
# {'namespace': '',
#  'vectors': {'id-1': {'id': 'id-1',
#                       'values': [0.568879, 0.632687092, 0.856837332, ...]},
#              'id-2': {'id': 'id-2',
#                       'values': [0.00891787093, 0.581895, 0.315718859, ...]}}}
curl -i -X GET "" \
  -H 'Api-Key: YOUR_API_KEY'
# Output:
# {
#   "vectors": {
#     "id-1": {
#       "id": "id-1",
#       "values": [0.568879, 0.632687092, 0.856837332, ...]
#     },
#     "id-2": {
#       "id": "id-2",
#       "values": [0.00891787093, 0.581895, 0.315718859, ...]
#     }
#   },
#   "namespace": ""
# }

Updating vectors

Updating an item by id is done the same way as inserting items. (Write operations in Pinecone are idempotent.)

The Upsert operation writes vectors into an index.


If a new value is upserted for an existing vector id, it will overwrite the previous value.

  1. Update the value of the item ("id-3", [3., 3.]):
index.upsert(vectors=[("id-3", [3.3, 3.3])])
curl -i -X POST \
  -H 'Api-Key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "vectors": [
        "id": "id-0",
        "values": [3.3, 3.3]
  1. Fetch the item again. We should get ("id-3", [3.3, 3.3]):
curl -i -X GET \
  -H 'Api-Key: YOUR_API_KEY'

Deleting vectors

The Delete operation deletes vectors, by id, from an index.

Alternatively, it can also delete all vectors from an index or namespace.


If you delete all vectors from a single namespace, it will also delete the namespace.

To delete vectors by their ids:

index.delete(ids=["id-1", "id-2"], namespace='example-namespace')
curl -i -X DELETE "" \
  -H 'Api-Key: YOUR_API_KEY'

To delete all vectors from a namespace:

index.delete(delete_all=True, namespace='example-namespace')
curl -i -X DELETE "" \
  -H 'Api-Key: YOUR_API_KEY'