LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Vector Databases for Embeddings with Pinecone

Kurs anzeigen

Anleitung zur Übung

  • 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.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# 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)
Code bearbeiten und ausführen