PostgreSQL Hybrid Search Course – Keyword (BM25) + Vector Retrieval
by freeCodeCamp.orgUploaded Posted 1:00:18 long81K views
Why watchA practical course for developers building PostgreSQL search applications with BM25, vector embeddings, rank fusion, and a FastAPI backend.
What this video covers
This 60-minute freeCodeCamp course, created by Beau, builds a Wikipedia search application using PostgreSQL for keyword retrieval, vector search, and hybrid ranking. The project uses pg_textsearch for BM25, pgvector-scale for vector indexing, and reciprocal rank fusion (RRF) to combine results. A FastAPI backend connects the database to a web interface.
The course starts at 0:00 with the project overview. At 4:06, it introduces the difference between finding matching documents and ranking them. The BM25 section at 7:20 explains inverse document frequency, term frequency, and document length, the factors used to calculate relevance scores.
Database setup begins at 11:39 with Tiger Data Cloud and PostgreSQL. At 14:06, the course covers environment configuration and database extensions, followed by loading Wikipedia data and creating the schema at 15:43. A native PostgreSQL full-text search baseline starts at 20:30, with EXPLAIN ANALYZE used to inspect query plans at 24:38.
At 27:40, the implementation moves to BM25 keyword retrieval through pg_textsearch. The next sections cover constructing search queries, highlighting matches with TS_HEADLINE at 32:32, and handling Boolean conditions and phrase searches at 36:18.
Semantic retrieval begins at 37:32 with embeddings. Vector indexing using pgvector-scale follows at 41:33. At 43:28, the course introduces RRF to combine keyword and semantic rankings. It then examines hybrid query plans at 46:58 and compares keyword, semantic, and hybrid results at 49:12.
The final sections connect a FastAPI backend with connection pooling at 52:13, test the web interface and adjust ranking weights at 54:06, and add records through transactional writes at 55:23. The course finishes at 57:24 with scale benchmarks and optimization topics. The creator also provides a GitHub repository containing the project code.
Written by HuiaHub from the creator's title, description and chapters. All credit for the video goes to freeCodeCamp.org.
Key takeaways
- Explain how BM25 uses term frequency, document frequency, and document length to rank matches.
- Configure PostgreSQL extensions and build a keyword search query using pg_textsearch.
- Generate embeddings and configure vector indexing with pgvector-scale.
- Combine keyword and semantic rankings using reciprocal rank fusion.
- Inspect PostgreSQL execution plans with EXPLAIN ANALYZE.
- Connect search queries to a FastAPI backend and adjust hybrid ranking weights.
Chapters
- 0:00Introduction & Project Overview (opens YouTube at this moment)
- 4:06Matching vs. Ranking & PostgreSQL Text Search (opens YouTube at this moment)
- 7:20Understanding BM25 (IDF, Term Frequency, & Document Length) (opens YouTube at this moment)
- 11:39Setting Up Tiger Data Cloud & PostgreSQL (opens YouTube at this moment)
- 14:06Environment Setup & Enabling Database Extensions (opens YouTube at this moment)
- 15:43Loading Wikipedia Dataset & Schema Setup (opens YouTube at this moment)
- 20:30Native PostgreSQL Full-Text Search Baseline (opens YouTube at this moment)
- 24:38Analyzing Query Plans with EXPLAIN ANALYZE (opens YouTube at this moment)
- 27:40Implementing BM25 Keyword Search with pg_textsearch (opens YouTube at this moment)
- 32:32Building the Keyword Search Query & Highlighting (TS_HEADLINE) (opens YouTube at this moment)
- 36:18Boolean Conditions & Phrase Search (opens YouTube at this moment)
- 37:32Semantic Search Fundamentals & Generating Embeddings (opens YouTube at this moment)
- 41:33Vector Indexing with pgvector-scale (opens YouTube at this moment)
- 43:28Reciprocal Rank Fusion (RRF) for Hybrid Search (opens YouTube at this moment)
- 46:58Query Plan Analysis for Hybrid Search (opens YouTube at this moment)
- 49:12Comparing Keyword, Semantic, and Hybrid Results (opens YouTube at this moment)
- 52:13Connecting the FastAPI Backend & Connection Pooling (opens YouTube at this moment)
- 54:06Testing the Web Interface & Weight Tuning (opens YouTube at this moment)
- 55:23Adding New Records via Transactional Writes (opens YouTube at this moment)
- 57:24Scale Benchmarks & Next Steps for Optimization (opens YouTube at this moment)
Sources
- PostgreSQL Hybrid Search Course – Keyword (BM25) + Vector RetrievalVideoPrimaryyoutube.com
- freeCodeCamp.orgChannelPrimaryyoutube.com
More videos
2:10:16beginnerMCP Security Fundamentals Course
A security course for developers working with MCP and AI agents, covering protocol basics, the OWASP MCP Top 10, real-world incidents, and defensive measures.
freeCodeCamp.org · 89K views ·
43:05beginnern8n Full Course – Architect Scalable AI Automations from Scratch
A 43-minute freeCodeCamp.org course that takes n8n from first workflow to agents, Slack approvals, error handling and cost monitoring, for builders new to the tool.
freeCodeCamp.org · 111K views ·
44:26intermediateBuild & Train a GLM-5.3-Flash Model From Scratch with Python
A freeCodeCamp.org walkthrough for developers who want to read, train and RL-tune a small GLM-5.3-Flash-style model in Python, with all code on GitHub.
freeCodeCamp.org · 150K views ·
20:51advancedTraining Your Own Agent Models With RL Is Now Practical - Jason Mancuso, Modal
A 21-minute talk from Modal for engineers with agents in production who want to train their own models with asynchronous RL instead of treating models as swappable backends.
AI Engineer · 3.2K views ·


