Postgres + pgvector hybrid search as agent memory
Sample story. Combining keyword and vector search in one database, and merging the rankings with reciprocal rank fusion.
TL;DR
- Vector search is good at meaning; keyword search is good at exact tokens like CVE IDs and function names.
- Postgres does both:
tsvectorfull-text search plus the pgvector extension's HNSW or IVFFlat indexes. - Reciprocal rank fusion merges the two lists with a score of , no score calibration needed.
Two librarians#
Ask one librarian for "books about a boy wizard" and she understands what you mean even if you never say the title. Ask another for "ISBN 0-7475-3269-9" and he finds it instantly, but would be lost with a vague description. Hybrid search asks both and merges their answers.
One query, two rankings#
What this sample leaves out#
A full story would include the SQL for both queries and the fusion step, index choices (HNSW vs IVFFlat), how to tune in reciprocal rank fusion, and when Postgres stops being enough. This sample stops here.
You are reading the overview. Switch to “Full deep dive” in the top bar for the mechanics, maths and code.
Why this matters to you
Hybrid RAG is already part of your HivePro stack, and doing it inside Postgres builds directly on the Postgres internals you're learning. It's also a cheap memory layer for Susanoo before you need a dedicated vector database.