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. Replace the truncated vectors below 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