AI and LLMs · Pattern

Hybrid search

Running keyword search and vector search on the same query and merging the two result lists, so you catch both exact matches and matches by meaning.

Search and memory · updated

How it works

Keyword search (usually ranked with BM25) is precise for names, codes and rare words, while vector search handles paraphrases and synonyms. Hybrid search runs both and fuses the lists. The common method is reciprocal rank fusion (RRF): each result scores 1 / (k + rank) in every list it appears in, with k often set to 60, and the scores are added. Because it uses rank positions rather than raw scores on different scales, it needs little tuning.

A reranker, a small model that reads the query next to each candidate, can then reorder the top few dozen results for extra precision. Elasticsearch, OpenSearch, Weaviate, Qdrant and MongoDB Atlas support hybrid queries directly, and in PostgreSQL it can be written as one SQL query that combines tsvector full-text search with pgvector. It is the usual retrieval setup for RAG over real-world documents.

Hybrid search vs the alternatives

More in AI and LLMs

Search and memory

All 22 AI and LLMs terms

Crafted in the dark. Shipped to the world.

Tell us what you are building. You get a private project space with a proposal and a line-by-line quote within a day.