Prompt
I'm building a search engine that mixes keyword and vector matching
Latest observation
Nov 21, 2026
OpenAI APIWeb search: off
That’s a solid approach. A hybrid search engine usually gives better relevance than using either keyword search or vector search alone.
A practical architecture looks like this:
-
Ingest and normalize documents
- Clean text, extract metadata, chunk long docs into passages.
- Store:
- full text / chunks
- keyword index fields
- vector embeddings
- metadata like title, tags, timestamp, author, permissions
-
Build two retrieval paths
- Keyword search: BM25 / inverted index for exact terms, entities, filters.
- Vector search: ANN index over embeddings for semantic similarity.
-
Combine results Common strategies:
- Score fusion: normalize keyword and vector scores, then weighted sum.
- Reciprocal Rank Fusion (RRF): robust and simple when score scales differ.
- Two-stage retrieval:
- retrieve top N from each
- merge
- rerank with a cross-encoder or LLM reranker
-
Tune weights
- Use more keyword weight for navigational queries, IDs, names, error codes.
- Use more vector weight for vague or conceptual queries.
- You can also detect query intent and choose weights dynamically.
-
Add filters and ranking signals
- Freshness, popularity, click logs, user context, permissions, locale, etc.
- These often matter as much as the retrieval method.
-
Evaluate
- Build a labeled test set.
- Measure MRR, nDCG, recall@k, and latency.
- Compare keyword-only, vector-only, and hybrid.
If you want, I can help with one of these next:
- a concrete hybrid ranking formula,
- an architecture diagram,
- sample code in Python,
- or how to tune weights for keyword vs vector search.