Prerequisites
- A Pinecone account and API key (get one).
- Python 3.10+.
- The Pinecone Python SDK:
pip install --upgrade pinecone.
Create an index and search
1
Set your API key
Set your API key as an environment variable so the SDK can authenticate:
2
Create an index
Define a schema with a full-text (BM25) field, then create the index. Only search fields belong in the schema; filterable metadata like
category goes in the documents and is indexed automatically.3
Load sample documents
Each document is a JSON object with a required
_id, the text field from your schema (indexed for full-text search), and any metadata you want to attach. Here, category is metadata: it’s not declared in the schema, but Pinecone indexes it automatically so you can filter on it.These five short strings are just samples. Real documents can carry many metadata fields (up to 40 KB per document), plus dense- or sparse-vector fields if your schema declares them, and you can upsert up to 1,000 per request.4
Run a full-text search
Search the index by choosing a scoring type with To narrow results, add a
score_by. Here, type: "text" scores documents by BM25 keyword relevance on the text field, so an exact identifier like E1042 surfaces the record that contains it.filter such as {"category": {"$eq": "product"}}. For exact phrase matching, use a query_string search instead (see the query syntax reference).Use your own data
Swap the sample documents for your own: keep the samedocuments.upsert() call and replace the text and metadata with your content. Each document needs a unique _id and the text field from your schema, plus any metadata fields you want to filter on.
Next steps
Rank by meaning
Add a
dense_vector field to your schema for semantic search, or combine it with text for hybrid search.Ingest your own files
Embed your own files with Pinecone Inference and search by meaning
Bring your own vectors
Upsert embeddings you already have directly.