Prompt
Elasticsearch vector search vs pgvector
Latest observation
Here’s a practical comparison of Elasticsearch vector search vs pgvector (PostgreSQL).
Quick summary
-
Choose Elasticsearch if you need:
- hybrid search at scale
- advanced text search + vector search together
- filtering/faceting/aggregations over large search workloads
- search relevance tuning, logs, or document retrieval pipelines
-
Choose pgvector if you need:
- vectors inside a normal relational database
- simpler architecture
- strong transactional consistency
- smaller to medium-scale semantic search
- easy joins with app data already in Postgres
Core difference
Elasticsearch
A search engine built for:
- full-text search
- relevance ranking
- filters, faceting, aggregations
- approximate nearest neighbor vector search
It’s best when search is a primary product feature.
pgvector
An extension to PostgreSQL that adds vector types and similarity search.
It’s best when vector search is one feature among many in an app already using Postgres.
Feature comparison
| Feature | Elasticsearch | pgvector |
|---|---|---|
| Full-text search | Excellent | Basic via Postgres text search |
| Vector search | Yes | Yes |
| Hybrid search | Very strong | Possible, but less specialized |
| Aggregations/facets | Excellent | Limited |
| Joins with app data | Weak | Excellent |
| Transactions/ACID | Limited search-layer semantics | Native Postgres ACID |
| Operational complexity | Higher | Lower |
| Scaling search workloads | Strong | Good, but DB-bound |
| Ecosystem for search relevance | Mature | Minimal |
| Filtering on metadata | Strong | Strong |
Performance and scale
Elasticsearch
- Usually better for large-scale retrieval
- Designed for high query throughput
- Better when vector search is part of a bigger search system
- Can combine keyword + semantic search efficiently
pgvector
- Great for moderate-scale semantic search
- Performance depends heavily on Postgres load and indexing approach
- Can become a bottleneck if vector search competes with OLTP traffic
- Works well if your dataset is not huge or query volume is moderate
Indexing
Elasticsearch
Supports ANN-style vector search using HNSW and related mechanisms depending on version/config.
- Strong tuning options
- Built for retrieval workflows
pgvector
Supports:
- HNSW
- IVFFlat
Good for many use cases, but you’ll likely need to think more about:
- index type choice
- query patterns
- maintenance/vacuuming
- table bloat
- impact on normal DB operations
Hybrid search
If you want keyword + vector together, Elasticsearch usually wins.
Example use case:
- search “wireless noise cancelling headphones”
- boost semantically similar items
- filter by brand, price, availability
- rank by relevance
Elasticsearch is made for this kind of query.
With pgvector, you can do it, but it’s more manual:
- combine
tsvectorfull-text search with vector similarity - tune rankings yourself
- less flexible for complex relevance strategies
Operational tradeoffs
Elasticsearch pros
- search-native
- powerful query DSL
- great observability for search use cases
- handles search-specific workloads well
Elasticsearch cons
- more moving parts
- harder ops than Postgres
- requires cluster management and tuning
- eventually consistent in many setups
pgvector pros
- simpler stack if you already use Postgres
- one source of truth
- transactions, constraints, joins, backups all familiar
- easier for teams already comfortable with SQL
pgvector cons
- Postgres wasn’t built primarily for retrieval search
- vector-heavy workloads can affect OLTP performance
- less advanced search relevance tooling
When to use which
Use Elasticsearch if:
- search is a core product feature
- you need autocomplete, fuzzy matching, faceting, ranking
- you need large-scale vector + keyword search
- you have lots of documents and search traffic
- you want to tune retrieval quality heavily
Use pgvector if:
- you already have Postgres
- you want to keep architecture simple
- your dataset is not massive
- you need vectors alongside relational data
- you’re building an MVP or internal tool
- transactional correctness matters more than search sophistication
Common recommendation
A good rule of thumb:
- Postgres + pgvector for early-stage products, internal tools, and simpler semantic search
- Elasticsearch for production search platforms, hybrid retrieval, and large-scale search systems
Typical architecture patterns
Pattern 1: Postgres-only
- App data in Postgres
- embeddings stored in pgvector
- semantic search directly in SQL
Best for simplicity.
Pattern 2: Elasticsearch-only search layer
- source of truth may be Postgres or another DB
- content indexed into Elasticsearch
- vectors + text search handled there
Best for search-heavy apps.
Pattern 3: Hybrid architecture
- Postgres as system of record
- Elasticsearch for search/retrieval
- sync via CDC / pipelines
Best for serious search applications.
Bottom line
If you want the best search experience, especially with hybrid keyword + vector retrieval, choose Elasticsearch.
If you want the simplest path and already rely on PostgreSQL, choose pgvector.
If you want, I can also give you:
- a decision tree,
- a cost/ops comparison, or
- an example of the same query implemented in both.