DEV Community

Kyle Anderson
Kyle Anderson

Posted on

Building Search That Doesn't Suck (Vector + Keyword)

If you replaced your application's standard keyword search with a pure Vector Search (Embeddings) over the last year, your users are probably frustrated. \n\nVector search is incredible for conceptual queries. But it is notoriously terrible at exact keyword matching (\"Show me invoice #INV-49201\"). \n\n*The Solution: Hybrid Search (BM25 + Vector)\n\nYou need to combine both methods and rank them. Here is the modern playbook for search:\n1. **Dense Vector Search: Embed your documents using an open-source embedding model (like bge-m3) to capture semantic meaning.\n2. **Sparse Keyword Search: Use an algorithm like BM25 to map exact token matches.\n3. **Reciprocal Rank Fusion (RRF): Run both searches in parallel, then mathematically combine the ranked lists so that a document scoring high in *both semantic meaning and exact keyword match rises to the top.\n\n*Tactical tip:* Stop using expensive vector databases for basic search. PostgreSQL with pgvector now supports HNSW indexing, meaning you can keep your vectors right next to your relational data.\n\nIf you found this helpful, I write a weekly newsletter for AI builders covering deep dives like this, new models, and tools. \nJoin here: https://project-1960fbd1.doanything.app

Top comments (0)