Menu

Hybrid Search in Postgres: When Embeddings Miss the Exact Match
📰

Hybrid Search in Postgres: When Embeddings Miss the Exact Match

DEV Community: typescript·Danny Holloran·6 days ago
#KX35iCBV
#devtotypescript#devto#dev#search#documents
Long article (1115 words) — no AI summary yet.
Reading 0:00
15s threshold

You ship a RAG feature, it demos beautifully, and then a user pastes ERR_SSL_PROTOCOL_ERROR into the search box. The top result is a vaguely related page about TLS certificates. The page that literally contains that error string is ranked eleventh. Nothing is broken. Embeddings are doing exactly what they were built to do: matching meaning . An error code, a SKU, a function name, or a person's surname has very little meaning to match on.

The fix most teams reach for is a second database or a reranking service. Before you do that, know that Postgres can run both kinds of search and merge them in a single query.

Two searches, two blind spots

Keyword search and semantic search fail in opposite directions.

Full-text search (Postgres tsvector ) is great at exact tokens. Search "invoice 4471" and it finds the document with "invoice 4471" in it. It is bad at synonyms: "cancel my plan" won't find a doc titled "Ending your subscription."

Vector search (pgvector) is great at paraphrase.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.