Get startedGet started for free

Fetching vectors

In this exercise, you've been provided with a list of ids containing IDs of different records in your 'datacamp-index' index. You'll use these IDs to retrieve the associated records and explore their metadata.

This exercise is part of the course

Vector Databases for Embeddings with Pinecone

View Course

Exercise instructions

  • Initialize the Pinecone connection with your API key.
  • Retrieve the vectors with IDs in the ids list from the connected index.
  • Create a list of dictionaries containing the metadata from each record in fetched_vectors.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Initialize the Pinecone client with your API key
pc = Pinecone(api_key="____")

index = pc.Index('datacamp-index')
ids = ['2', '5', '8']

# Fetch the vectors from the connected Pinecone index
fetched_vectors = ____

# Extract the metadata from each result in fetched_vectors
metadatas = [fetched_vectors['____'][____]['____'] for id in ids]
print(metadatas)
Edit and Run Code