Hybrid BM25 + HNSW + RRF Search in SurrealDB for Better Developer Docs
Implement BM25 full‑text indexes, HNSW vector indexes, and use search::rrf() in SurrealDB to fuse results for improved relevance.
Implement BM25 and HNSW indexes in SurrealDB, use search::rrf() to combine rankings, and test on your internal docs.
Summary
The author demonstrates a hybrid search strategy that merges BM25 full‑text scoring, HNSW vector search, and Reciprocal Rank Fusion (RRF) within SurrealDB’s database layer. SurrealDB natively supports full‑text indexes with BM25 field scoring, HNSW vector indexes, and a search::rrf() function to fuse rankings. The implementation includes post‑retrieval boosting based on collection or type, and the author shows a concise example query that retrieves full‑text and vector scores before applying RRF. Hybrid search consistently outperforms vector‑only systems for technical documentation, where exact term matches remain critical. The article references a detailed blog post that walks through architecture, queries, analyzers, and the reranking pipeline. No external reranking engines are required, keeping the solution lightweight and fully contained in the database.
SurrealDB’s native hybrid search capability can be leveraged immediately for internal documentation or customer‑facing knowledge bases, improving relevance without additional infrastructure.
Key changes
- SurrealDB supports BM25 full‑text indexing with field scoring
- HNSW vector indexes enable semantic search
- search::rrf() fuses BM25 and vector rankings
- Post‑retrieval boosting based on collection/type is available
- Hybrid search outperforms vector‑only for technical queries
- Implementation is fully contained in the database layer
- Example query demonstrates combining fts_score and vector_score
- Hybrid search improves relevance for developer documentation