Your first Pinecone index
With your Pinecone client initialized, you're all set to begin creating an index! Indexes are used to store records, including the vectors and associated metadata, as well as serving queries and other manipulations. As you progress through the course, you'll see how these different steps build up to a modern AI system built on a vector database.
If you accidentally create a valid index that doesn't meet the specifications detailed in the instructions, you'll need to add the following code before your .create_index()
code to delete it and re-create it:
pc.delete_index('my-first-index')
The Pinecone
class has already been imported for you.
This exercise is part of the course
Vector Databases for Embeddings with Pinecone
Exercise instructions
- Import the
ServerlessSpec
class frompinecone
. - Initialize the Pinecone connection using your API key.
- Create a serverless index called
"my-first-index"
to hold vectors with256
dimensions, and configure the index for the'aws'
cloud platform in the'us-east-1'
region.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import ServerlessSpec
from pinecone import ____
# Initialize the Pinecone client with your API key
pc = Pinecone(api_key="____")
# Create your Pinecone index
pc.____(
name="____",
dimension=____,
spec=____(
cloud='____'
region='____'
)
)