Pinecone is the leading managed vector database service for AI applications. It supports fast storage and retrieval of embeddings for RAG, semantic search, and recommendation systems. Easy integration with LangChain and OpenAI.
Create Index on Pinecone Console
Sign up for an account and create a new index with the correct vector dimension suitable for the embedding model you will use.
Go to Pinecone Console > Create Index, name the index, select dimension = 1536 (if using OpenAI text-embedding-3-small) and metric = cosine.
Remember the exact dimension of the embedding model — incorrect dimension will cause data write failures.
Obtain API Key and Configure SDK
Retrieve the API key from the console and initialize the Pinecone client in your application code.
Install `pip install pinecone-client`, then initialize `pc = Pinecone(api_key="YOUR_KEY")` and `index = pc.Index("index-name")`.
Store the API key in an environment variable, do not hardcode it directly into the code.
Create Embedding for Product Data
Convert the description of each product into a vector using the embedding model before writing to Pinecone.
For each product, call the embedding API (e.g., OpenAI) to obtain the vector, along with metadata such as name, price, and category.
Combine the product name and detailed description into the same text block before creating the embedding to improve accuracy.
Write Data to Index in Batches
Upsert all product vectors into Pinecone in batches to avoid timeouts.
Call `index.upsert(vectors=[(id, vector, metadata), ...])` in batches of about 100 products at a time.
Use the real product ID (SKU) as the vector ID to make it easier to update when the product changes.
Query Semantic Search and Combine Filter
Build a search API that accepts customer query sentences, converts them into vectors, and queries Pinecone.
Call `index.query(vector=query_embedding, top_k=10, filter={"category": "furniture"}, include_metadata=True)`.
Combine filters based on metadata (category, price range) with semantic search to ensure results are both relevant and within the customer's desired scope.
No reviews yet - be the first to share your experience.
Log in to leave a review.
Pros
Cons
A niche e-commerce platform specializing in furniture wants customers to find products using natural descriptive sentences instead of just keyword filtering.
Problem
Traditional keyword searches miss many relevant products when customers type descriptions like 'compact desk for a bedroom'.
Solution
Use Pinecone to store product description embeddings, combining semantic search to return products that match the actual search intent.
A B2B SaaS company offers a document Q&A chatbot feature for various business clients.
Problem
Need to ensure that the document data for each client is completely separated and not mixed during queries.
Solution
Use a separate namespace in Pinecone for each client, ensuring that each query only searches within their specific data range.