What happens when a customer types “my card was charged twice” into a support search box? A keyword engine looks for those exact words. A vector database looks for what the sentence means. The two systems often return wildly different results, and that gap is exactly why the “vector database vs search engine” debate keeps showing up in architecture reviews. (Building a recovery drill for a managed database)
The short answer: most teams don’t have to pick one. The longer answer involves inverted indexes, graph-based nearest-neighbor search, and a few operational realities that vendor slide decks tend to skip. Here’s a practical breakdown of how each system works, where it wins, and how to combine them without doubling your infrastructure bill.
What Each System Is Actually Built to Do
A search engine such as Elasticsearch, OpenSearch, or a Solr deployment built on Apache Lucene is organized around the inverted index. It maps every word to the documents that contain it, then ranks matches with algorithms like BM25, which weigh term frequency, rarity, and document length. The Apache Lucene project documentation explains the inverted-index model and scoring approach that underpin most of these engines.
A vector database stores embeddings: dense arrays of numbers, often hundreds or thousands of dimensions, produced by a machine-learning model. Similarity is measured by distance in that space, usually cosine or dot product. The database’s core job is approximate nearest-neighbor (ANN) search, finding the closest vectors without scanning every row.
| Dimension | Search Engine | Vector Database |
|---|---|---|
| Core index | Inverted index (terms to documents) | ANN index over embeddings |
| Matching model | Lexical, exact terms | Semantic, meaning-based |
| Typical ranking | BM25 and variants | Distance metric (cosine, L2) |
| Strength | Precision on names, codes, filters | Paraphrase and synonym recall |
| Weakness | Misses synonyms and paraphrase | Weak on exact IDs and rare tokens |
| Maturity | Decades of cluster tooling | Rapidly evolving since 2017 |
That last row matters more than it looks. Search engines have had twenty-plus years of operational hardening around sharding, replication, and recovery. Vector stores are younger and moving fast.
How Approximate Nearest-Neighbor Search Works

Most vector databases rely on HNSW, or Hierarchical Navigable Small World graphs. The Malkov and Yashunin paper on HNSW search describes a layered graph structure where queries hop through long links at the top and refine through denser links below, giving roughly logarithmic search complexity. It is the default index in FAISS, hnswlib, and pgvector’s HNSW option.
HNSW has three parameters worth knowing before you tune anything:
- M controls how many links each node keeps. Higher M means better recall and more memory.
- efConstruction sets search effort during index building. Higher values produce a better graph but slower builds.
- efSearch sets effort at query time. Raising it improves recall and adds latency.
The trade-off is never free. A common mistake is benchmarking with default parameters, declaring victory, and then discovering that recall collapses once real filters enter the query. Another is rebuilding the whole index every time embeddings change, which is expensive at scale.
Where Search Engines Still Win
Lexical search is not a legacy technology waiting to be replaced. It is genuinely better at several jobs:
- Exact identifiers. Part numbers, error codes, SKUs, and legal citations. Embeddings blur these into fuzzy similarity, which is the opposite of what you want.
- Rare and out-of-vocabulary terms. A model that never saw a product codename during training has no useful representation for it.
- Explainability. BM25 scores can be traced to specific term matches. “Why did this rank first?” has a defensible answer.
- Aggregations and faceting. Counting, bucketing, and filtering across millions of documents is a solved problem in these engines.
For a support portal where users paste order numbers, or an internal wiki where people search for exact policy names, pure vector search will frustrate them.
Where Vector Databases Pull Ahead
Semantic retrieval shines when users don’t know the vocabulary. Consider a knowledge base where one article says “cancel your subscription” and the user types “stop paying monthly.” No shared keywords, perfect semantic match. That is the vector database’s home turf.
Other strong cases:
- Multilingual retrieval. A single embedding space can match a Spanish query to an English document.
- Multimodal search. Image, audio, and text embeddings can live in one index.
- Long-tail natural language. Conversational questions with no obvious keyword anchor.
- Recommendation and deduplication. “Find items like this one” is a nearest-neighbor problem by definition.
If your product is an AI assistant answering open-ended questions over a document corpus, vector retrieval is usually the backbone of the retrieval step.
The Convergence: Hybrid Search Is the Default Answer
Here’s the part that surprises people new to the field: the binary framing is mostly obsolete. Elasticsearch added `dense_vector` fields and kNN search, with kNN reaching general availability in version 8.0 in early 2022. OpenSearch shipped k-NN as a plugin. Meanwhile, vector databases added keyword filters, sparse vectors, and BM25-style scoring.
The standard production pattern is hybrid retrieval: run a lexical query and a vector query in parallel, then merge the ranked lists. A frequent merge method is reciprocal rank fusion, which combines rankings without needing to normalize incompatible score scales. In practice, hybrid setups tend to beat either mode alone on mixed workloads, though the size of the gain depends heavily on the dataset.
A practical hybrid recipe that works well:
- Retrieve the top 50 candidates with BM25.
- Retrieve the top 50 candidates with vector similarity.
- Fuse the lists with reciprocal rank fusion.
- Apply a cross-encoder reranker to the top 20.
- Return the top 5 to the application.
That pipeline is more work than a single query, but it handles both the user who pastes an error code and the user who describes a problem in their own words.
Filtering Is the Hard Part Nobody Warns You About
Combine a metadata filter with ANN search and things get complicated. Pre-filtering restricts the candidate set before graph traversal, which can break graph connectivity and hurt recall. Post-filtering searches first and discards afterward, which can return too few results when the filter is selective. Neither approach dominates, and every engine handles it differently.
In practice, the teams that struggle most are the ones that treat filtering as an afterthought. If your queries routinely filter by tenant, date range, or permission scope, test recall under those exact conditions before committing to an engine. This connects to a broader concern: separating tenant data in an enterprise assistant is a retrieval-design problem as much as a security one, and the filter strategy you choose shapes both.
The Postgres Option Most Teams Underestimate
Not every project needs a dedicated vector database. The pgvector extension for PostgreSQL adds vector column types plus IVFFlat and HNSW indexes, letting you keep embeddings next to your relational data. For moderate scale, that eliminates a whole service from your stack, along with its backups, monitoring, and access controls.
When does pgvector stop being enough? Roughly when you cross into tens of millions of high-dimensional vectors with tight latency budgets, or when you need GPU-accelerated index builds. Below that line, the operational simplicity usually wins. If you’re weighing that decision, a clearer way to track cloud data transfer costs helps, because moving embeddings between services is rarely free.
Benchmarks: Read Them With Suspicion
Public benchmark suites compare ANN algorithms on recall versus queries per second, and they are genuinely useful for understanding algorithm families. But results swing wildly with dataset, hardware, dimensionality, filtering, and parameter tuning. Vendor-published benchmarks, in particular, tend to use favorable configurations.
A few habits that save grief:
- Reproduce benchmarks on your own data sample before signing anything.
- Measure recall against exact search on a held-out query set, not against the vendor’s numbers.
- Test with realistic filters and realistic query distributions.
- Track p95 and p99 latency, not averages.
Operational Realities That Decide the Choice
Feature comparisons are easy. Operations are where projects succeed or fail.
Index refresh. Embeddings change when documents change or when you upgrade the embedding model. A model upgrade can mean re-embedding the entire corpus, which is a batch job with real cost. Plan for versioned embeddings and the ability to run two indexes side by side during migration.
Cluster maturity. Search engines bring mature tooling for snapshots, rolling upgrades, and shard rebalancing. Vector databases vary widely here. A recovery drill for a managed database is worth running before you trust any new store with production traffic.
Cost shape. Vector indexes are memory-hungry. HNSW graphs live in RAM for fast access, and high dimensionality multiplies the bill. Budget for memory first, compute second.
Team skills. A team that already runs Elasticsearch will ship a hybrid search feature faster than one learning a new vector store from scratch. Familiarity is a legitimate architectural input.
Common Mistakes in Practice
A few patterns show up again and again in failed migrations:
- Ripping out lexical search entirely. Users then search for exact error codes and get nothing useful.
- Skipping the reranker. First-stage retrieval is recall-oriented; without a reranker, precision suffers.
- Ignoring chunking strategy. Embedding whole documents produces muddy vectors. Chunk by semantic boundary, not fixed character count.
- Using one embedding model everywhere. A model tuned for code will underperform on prose.
- Forgetting evaluation. Build a labeled query set early, or you’ll be tuning blind.
How to Decide
Start with the query patterns, not the technology. If users search with exact terms, codes, and filters, a search engine is the foundation. If they ask questions in natural language or search across languages and modalities, vector retrieval earns its place. If both are true, and they usually are, plan for hybrid from day one.
For teams building AI features on top of retrieval, understanding what platform engineers do on enterprise AI teams clarifies who owns the embedding pipeline, the index, and the evaluation harness. That ownership question causes more delays than any algorithm choice. And when you’re hiring or building a team, knowing what a useful AI engineering portfolio can show helps you spot people who have actually shipped retrieval systems rather than just read about them.
Conclusion
The vector database versus search engine question is really a question about query intent. Lexical engines excel at precision, exact matching, and mature operations. Vector databases excel at meaning, paraphrase, and cross-modal similarity. The strongest production systems in 2025 and beyond run both, fuse the results, and rerank before showing anything to a user.
Pick the retrieval mode that matches your users’ actual queries, then add the other one when you can measure the gap. Measure recall, watch your memory costs, and test filters under realistic conditions. Do that, and the architecture debate becomes a much shorter conversation.
Frequently Asked Questions
Is a vector database a replacement for a search engine?
No, not for most workloads. A vector database handles semantic similarity well but struggles with exact identifiers, rare terms, and aggregation-heavy queries. Search engines remain stronger for lexical precision and faceted filtering. Most production systems use both together rather than choosing one.
Can Elasticsearch or OpenSearch do vector search?
Yes. Elasticsearch supports dense vector fields with kNN search, generally available since version 8.0, and OpenSearch offers k-NN through a plugin. That means teams already running a search cluster can add semantic retrieval without introducing a separate database, which is often the lowest-friction path to hybrid search.
When should I use pgvector instead of a dedicated vector database?
pgvector makes sense when your vector count is moderate, your latency budget is reasonable, and you value operational simplicity. Keeping embeddings beside relational data avoids a second service to back up and secure. Above tens of millions of high-dimensional vectors with tight latency targets, a dedicated store usually becomes worthwhile.
What is hybrid search and why does it matter?
Hybrid search runs a keyword query and a vector query in parallel, then merges the ranked results, often with reciprocal rank fusion. It matters because lexical and semantic retrieval fail in different ways. Combining them covers exact-match queries and paraphrase queries in one pipeline, which tends to improve overall result quality.
Why does metadata filtering hurt vector search accuracy?
Approximate nearest-neighbor indexes like HNSW traverse a graph, and restrictive filters can disconnect parts of that graph or shrink the candidate pool. Pre-filtering may reduce recall; post-filtering may return too few results. Every engine handles this differently, so test recall with your real filters before committing.
Do I need to re-embed my documents when I change models?
Yes, in almost every case. Different embedding models produce incompatible vector spaces, so you cannot mix old and new vectors in one index. Plan for a full re-embedding batch job, and run the old and new indexes side by side during migration so users see no gap in service.







