Prompt

How do I add vector search to a RAG app without breaking keyword search?

Technology / Databases2 observationsLast seen Oct 14, 2026

Latest observation

Oct 14, 2026OpenAI APIWeb search: off

A good way to add vector search to a RAG app without losing keyword search is to use a hybrid retrieval design rather than replacing your current search.

Recommended approach: hybrid search

Use both:

  • Keyword search for exact matches, names, IDs, rare terms, and precision
  • Vector search for semantic similarity, paraphrases, and concept matching

Then combine the results with a rank fusion or weighted scoring step.


Practical architecture

1) Keep your existing keyword index

If you already have:

  • Elasticsearch / OpenSearch
  • Postgres full-text search
  • Lucene / Solr / Meilisearch

don’t remove it. It still handles:

  • Exact product names
  • Error codes
  • Acronyms
  • Rare proper nouns
  • Compliance/legal phrases

2) Add embeddings and a vector index

For each document chunk:

  • Generate an embedding
  • Store it alongside the chunk text and metadata

Use:

  • pgvector
  • Pinecone
  • Weaviate
  • Milvus
  • Elasticsearch/OpenSearch vector fields
  • FAISS for local prototypes

3) Retrieve from both systems

For each query:

  • Run keyword retrieval
  • Run vector retrieval

Then merge results.


Best ways to merge results

Option A: Reciprocal Rank Fusion (RRF)

This is often the safest default.

It works by giving higher scores to docs that appear near the top in either list.

Why it’s good:

  • Simple
  • Robust
  • Doesn’t require score normalization
  • Preserves strong keyword hits

Option B: Weighted score combination

Combine normalized keyword and vector scores.

Example:

  • Final score = 0.6 * keyword_score + 0.4 * vector_score

Useful when you have well-calibrated scores, but harder to tune.

Option C: Two-stage retrieval

  1. Use keyword + vector to get top 50–200 candidates
  2. Re-rank with a cross-encoder or LLM-based reranker

This usually gives the best quality, while preserving keyword precision.


A safe default pipeline

A strong practical setup is:

  1. Keyword search top 20
  2. Vector search top 20
  3. Merge with RRF
  4. Optional rerank top 20
  5. Send top chunks to the LLM

This ensures keyword results still surface even if vector search is noisy.


Important design tips

Preserve exact-match boosting

Boost documents when they contain:

  • Query terms in title
  • Exact phrase matches
  • Rare tokens
  • IDs / codes / names

This prevents vector search from burying precise results.

Chunk carefully

Too-large chunks hurt both keyword and vector search. A common sweet spot:

  • 200–500 tokens per chunk
  • Some overlap

Store metadata for filtering

Use filters like:

  • document type
  • date
  • tenant/user permissions
  • source
  • language

Filtering before ranking improves both retrieval methods.

Normalize scores if combining

Keyword scores and vector similarity scores are usually on different scales. If you combine them directly, one can dominate. Use:

  • min-max normalization
  • z-score normalization
  • or just RRF to avoid the issue

If you already have Elastic/OpenSearch

You can often do hybrid search in one engine:

  • BM25 for keyword retrieval
  • kNN/vector search for embeddings

Then combine with built-in hybrid ranking or your own fusion.

This is often the easiest migration path.


Common mistake to avoid

Don’t replace keyword search with vector search alone.

Why not:

  • Vector search can miss exact strings
  • It can return semantically related but wrong documents
  • It struggles with short, numeric, or highly specific queries

Keyword search remains essential in RAG systems.


Simple implementation pattern

Pseudo-flow:

keyword_results = keyword_search(query, top_k=20)
vector_results = vector_search(query_embedding, top_k=20)

combined = reciprocal_rank_fusion(keyword_results, vector_results)
reranked = rerank(query, combined[:20])

context = build_context(reranked[:5])
answer = llm.generate(query, context)

Rule of thumb

If your queries are a mix of:

  • exact identifiers
  • natural language questions
  • domain jargon

then hybrid retrieval is almost always the right choice.


If you want, I can also give you:

  1. a reference architecture,
  2. a Postgres/pgvector implementation, or
  3. an Elasticsearch/OpenSearch hybrid search example.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (2 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.