Prerequisites
- A Pinecone account and API key (get one).
- Python 3.10+.
- The Pinecone Python SDK:
pip install --upgrade pinecone.
Upsert your vectors and search
1
Set your API key
Set your API key as an environment variable so the SDK can authenticate:
2
Create an index with a dense-vector field
Set
dimension to match your embedding modelโs output, and pick a distance metric (cosine, dotproduct, or euclidean). Only the vector field goes in the schema; other fields like text are stored on the documents (non-schema fields are stored as metadata, capped at 40 KB per document).3
Upsert your vectors
Each document carries its
embedding (a list of floats matching the schemaโs dimension) plus any fields you want to store. The vectors below are stand-ins with the right dimension. Replace them with your real embeddings.4
Search by vector similarity
Embed your query with the same model you used for the documents, then rank by the dense-vector field (
embedding).Next steps
Match keywords
Add a
full_text_search field to your schema for keyword search, or combine it with your vectors for hybrid search.Data modeling
How to design a schema for your workload