Building an AI Powered Search That Actually Works
AI powered search that works is a hybrid retrieval system. It combines keyword search for exact match precision, semantic search for intent matching, and a reranker to put the right results at the top. The architecture is more complex than either approach alone. The quality is dramatically better than either alone. The cost is modest at modern model prices.
Written by Yashveer Singh, founder of Yashveer Labs.
What you actually need to know
- Hybrid retrieval beats pure semantic or pure keyword.
- The reranker turns candidates into a clean top result list.
- pgvector is fine for starting. Move up only when scale demands.
- Caching the top queries cuts the cost dramatically.
- The eval suite is what keeps the pipeline honest.
| Layer | Purpose | Tools |
|---|---|---|
| Keyword search | Precision on specific terms | Postgres FTS, Elasticsearch, Typesense |
| Semantic search | Recall on intent | pgvector, Pinecone, Weaviate, Qdrant |
| Fusion | Combine results | Reciprocal rank fusion |
| Reranker | Top result quality | Cohere Rerank, BAAI bge-reranker |
| Eval suite | Quality control | Labeled query set |
The core argument
AI powered search is one of the features that founders most reliably build badly. The pattern is consistent. The team reads about embeddings, builds a semantic search pipeline, ships it, and discovers that the results are worse than the keyword search they replaced. The user types a specific term, gets back five vaguely related results, and decides the new search is broken.
The fix is not abandoning semantic search. The fix is hybrid retrieval. Run keyword and semantic searches in parallel. Combine the results. Pass the combined candidates through a reranker. The output beats either pure approach.
The reason the hybrid approach wins is that keyword and semantic search fail in complementary ways. Keyword search has high precision and low recall. Semantic search has high recall and low precision. The fusion captures both. The reranker reorders the combined list to put the highest quality results at the top.
The architecture is more complex than either pure approach. The cost is also higher. Both are justified by the quality improvement. A well built hybrid search feels like the user is being understood. A poorly built one feels like the user is fighting the system.
The architecture
The corpus is ingested into two stores. A keyword store like Postgres full text search or Elasticsearch. A vector store like pgvector with embeddings from a model like text-embedding-3 or an open source alternative.
The query pipeline issues two retrievals. A keyword search returns the top K candidates. A semantic search returns the top K candidates. Both K values are typically 20 to 50.
The fusion step combines the two ranked lists. Reciprocal rank fusion is the standard. The combined list has up to 2K candidates with merged ranks.
The reranker scores each candidate against the query. Cohere Rerank, BAAI bge-reranker, or a custom cross encoder. The reranker returns the top N final results, typically 5 to 10.
The cache layer stores the top results for the most common queries. The cache invalidates when the corpus changes meaningfully. The cache cuts the cost and latency for repeated queries.
How much does this cost
| Cost layer | Modest scale | High scale |
|---|---|---|
| Vector storage | 50 to 300 USD per month | 500 to 3000 USD |
| Embedding generation at ingest | One time per document, then on changes | Same |
| Embedding generation at query | A fraction of a cent per query | Scales |
| Reranker calls | 0.001 USD per query roughly | Scales |
| Cache layer | Negligible | Modest |
| Total at 10k queries per day | 200 to 800 USD per month | Higher |
The numbers come from projects I have worked on. The reranker cost is the largest single line item for most teams. Caching the top queries cuts it significantly.
Features the search must have
- Hybrid retrieval combining keyword and semantic.
- A reranker for top result quality.
- Caching for popular queries.
- A clear path to update the corpus and invalidate the cache.
- Multi tenant isolation in the vector store.
- Telemetry on query latency, result count, and click through.
- An eval suite with labeled queries.
- A clear path for the user to refine the query.
Expert opinion
The teams that ship great AI powered search treat retrieval as an engineering problem with measurable quality. Recall, precision, mean reciprocal rank. They run the eval on every change. The teams that ship bad AI powered search treat retrieval as a vibe. They ship the embedding model they read about and never measure. The first kind of team improves over time. The second kind plateaus at mediocrity.
>
Yashveer Singh, founder of Yashveer Labs
How this played out on a real project
A SaaS client added search to their knowledge base product. The first version was pure semantic search using embeddings. The results were impressive in demos. The customer support team reported that users complained the new search was worse than the old keyword search.
We migrated to hybrid retrieval. Postgres full text for keyword, pgvector for semantic, reciprocal rank fusion for combination, and Cohere Rerank for the top results. The deployment took three weeks.
The customer satisfaction with search jumped immediately. Specific term queries that had been failing now succeeded. Intent based queries continued to succeed. The team has not made significant changes to the retrieval pipeline in twelve months because it just works.
For more on the related work, see RAG retrieval augmented generation for SaaS when it helps and when it does not and the search problem why adding it late always hurts.
Common mistakes teams make
- Pure semantic search. Loses on specific terms.
- Pure keyword search. Loses on intent matching.
- No reranker. The top results are noisy.
- No eval suite. Quality drifts.
- Mixing tenants in the vector store.
- No caching. The cost grows fast.
- Embedding a model that does not match the language. Choose embeddings that match your content language and domain.
- Treating search as solved once it is deployed.
A 30 day plan to ship hybrid search
- Week one. Ingest the corpus into the keyword store. Build the baseline keyword search. Measure on the eval set.
- Week two. Ingest the corpus into the vector store. Build the semantic search. Measure on the eval set.
- Week three. Build the fusion step. Add the reranker. Measure the hybrid against the baselines.
- Week four. Add caching, telemetry, and the user refinement path. Ship.
For more on the related work, read SaaS search at scale Postgres full text vs Algolia vs Typesense and vector databases compared Pinecone Weaviate pgvector Qdrant. On the broader AI side, the difference between an AI wrapper and an AI product is the natural next read.
Frequently asked
The reason my name is on this page
My name is on this page because I wrote what is on this page. Yashveer Singh. Full stack developer. Founder of Yashveer Labs. The portfolio is on the homepage. The projects are live. The code is real. The work is provable. If you have read this far, you already know whether the voice matches the standard you are looking for. The next move is yours.
Posts that line up with this one.
- AI Integration and Vibe Coding Rescue
Streaming AI Responses to Users: An Architecture Primer
Streaming AI responses is a UX decision with real backend consequences. Here is how to implement it without making your product unreliable.
- AI Integration and Vibe Coding Rescue
The Compliance Risk of AI in B2B SaaS
Adding AI features to B2B SaaS creates compliance questions your customers will ask. Here is how to think through the risk before you ship.
- AI Integration and Vibe Coding Rescue
The Cost of Running LLMs in Production: A Realistic Budget
LLM API costs in production look different from development costs. Here is how to build a realistic budget before your AI features go live.
- AI Integration and Vibe Coding Rescue
Human in the Loop Design: The Pattern Behind Trustworthy AI Features
AI features that users trust are rarely fully autonomous. They are designed with human checkpoints at the moments where the cost of an AI error is high. Here is the pattern and how to apply it.