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.

Learn more

Our Learn section explains the basics of vector databases and similarity search as a service.

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:

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

Pinecone indexes each have their own DNS endpoint.

Summarize

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

pythoncurl
index.summarize()
curl -i -X GET \
  -H 'Api-Key: YOUR_API_KEY_HERE'
  'https://pinecone-index-example-project.svc.beta.pinecone.io/summarize'

Fetching a vector

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

Fetch items by their ids:

pythoncurl
index.fetch(ids=["id-1", "id-2"])
curl -i -X GET \
  -H 'Api-Key: YOUR_API_KEY_HERE' \
  'https://{index_name}-{project_name}.svc.{environment}.pinecone.io/vectors/fetch?ids=string&namespace=%22%22'

Updating a vector

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 a namespace.

note

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.]):
pythoncurl
index.upsert(vectors=[("id-3", 3.3 + np.zeros(2))])
curl -i -X POST \
  -H 'Api-Key: YOUR_API_KEY_HERE' \
  -H 'Content-Type: application/json' \
  'https://hello-pinecone-example-project.svc.beta.pinecone.io/vectors/upsert' \
  -d '{
    "vectors": [
      {
        "id": "id-0",
        "values": [3.3, 3.3]
      }
    ]
  }'
  1. Fetch the item again. We should get ("id-3", [3.3, 3.3]):
pythoncurl
index.fetch(ids=["id-3"])
curl -i -X GET \
  -H 'Api-Key: YOUR_API_KEY_HERE' \
  'https://{index_name}-{project_name}.svc.beta.pinecone.io/vectors/fetch?ids=id-3'

Deleting vectors

The Delete operation deletes vectors, by id, from a single namespace.

Alternatively, it can also delete all vectors from a single namespace.

note

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

To delete vectors by their ids:

pythoncurl
index.delete(ids=["id-1", "id-2"], namespace='example-namespace')
curl -i -X DELETE \
  -H 'Api-Key: YOUR_API_KEY_HERE' \
  'https://{index_name}-{project_name}.svc.{environment}.pinecone.io/vectors/delete?ids=id-1&ids=id-2&namespace=example-namespace'

To delete all vectors from a namespace:

pythoncurl
index.delete(delete_all=True, namespace='example-namespace')
curl -i -X DELETE \
  -H 'Api-Key: YOUR_API_KEY_HERE' \
  'https://{index_name}-{project_name}.svc.{environment}.pinecone.io/vectors/delete?delete_all=true&namespace=example-namespace'