ChatNexus.io Knowledge Base

Hybrid Search in PostgreSQL: Combining Keyword and Vector Retrieval

Someone searches for “refund window” and expects the exact phrase. Someone else asks, “Can I get my money back after two weeks?” Both questions may describe the same policy, but a keyword index and a vector index will notice different things. Hybrid search combines those strengths instead of asking one method to solve every retrieval problem.

Lexical and semantic search see different signals

PostgreSQL full-text search is good at words, phrases, stemming, and exact terms that matter to a user. Vector search is good at meaning when the wording changes. A product code, legal term, error message, or person’s name may need lexical matching; a paraphrased question may need semantic matching.

Blend scores with care

Run both searches with the same tenant, permission, status, and freshness filters. Then combine the candidates using a method you can explain, such as a weighted score or reciprocal rank fusion. Do not assume the raw distance from one index can be added directly to the score from another; the scales and failure modes are different.

Reranking is useful, not magical

A reranker can look at a smaller candidate set and decide which passages answer the question most directly. Keep the candidate set broad enough to include the right source, and preserve citations so the final answer can be checked. If every stage is opaque, a better score may still leave you unable to explain a bad answer.

Test the questions people actually ask

Build an evaluation set with exact names, misspellings, paraphrases, short queries, long questions, and requests where the correct answer is “not found.” Compare lexical-only, vector-only, and hybrid retrieval on recall, citation quality, latency, and cost. PostgreSQL’s full-text search documentation and the pgvector project are useful starting points, but your own documents and filters decide which approach wins.