Elasticsearch vs pgvector

Elasticsearch
hybridFree (self-hosted, Elastic License v2 / SSPL)
pgvector
self-hostedFree (open-source PostgreSQL extension)
Hybrid Search
Metadata Filtering
Multi Tenancy
Managed Embeddings
Mcp Server
Serverless
Pricing
Free (self-hosted, Elastic License v2 / SSPL)Elastic Cloud Hosted $99+/mo (Standard, Gold, Platinum, Enterprise)Elasticsearch Serverless (pay per use)
Free (open-source PostgreSQL extension)Available on managed Postgres: Supabase, Neon, RDS, Cloud SQL, Crunchy Bridge
Open Source
Self-Hosted
SDK Languages
pythonjavascripttypescriptgojavarubyphpcsharprust
pythonjavascripttypescriptgojavarubyrustcsharpphp
Frameworks
langchainllamaindexvercel-aihaystack
langchainllamaindexvercel-aihaystack
Compliance
soc2hipaagdprpci-dssiso27001
soc2hipaagdprpci-dss
Best For
Hybrid search at scale on top of mature search infrastructure — combine BM25, ELSER sparse vectors, and dense vectors in one query
Teams already running Postgres who want vector search without adding a new database — ACID, joins, and one operational story
Limitations
Heavier and more memory-hungry than purpose-built vector engines; license is no longer pure Apache 2.0; vector-only workloads are overserved by Elasticsearch's full feature surface
Slower at scale than purpose-built engines; no native multi-tenancy primitives beyond schemas; hybrid search and serverless depend on the host platform (Supabase, Neon, etc.), not pgvector itself

Supported Not supported Unverified

Elasticsearch and pgvector both add vector search to platforms you might already run. Elasticsearch is a heavyweight search engine; pgvector is a small extension on Postgres. The decision is whether your operational data is search-shaped or relational.

Where Elasticsearch wins

  • Hybrid retrieval is the default, not an add-on. Dense + ELSER sparse + BM25 with reciprocal rank fusion in a single query. pgvector + tsvector can do hybrid search, but you build the fusion yourself.

  • inference API hosts embedding and reranker models in-cluster. pgvector has no embedding pipeline of its own.

  • Built for vector workloads at hundreds of millions of vectors. Postgres with pgvector starts to feel the heat in that range, especially with concurrent writes.

Where pgvector wins

  • One database, one backup, one auth story. Vectors next to your users, documents, and audit logs. ACID transactions span everything.

  • Row-level security enforces multi-tenancy in the database. Elasticsearch isolates with document-level security or separate indices — both work, but neither matches Postgres RLS for declarative simplicity.

  • No new vendor or operational surface. Postgres is already in most stacks. Elasticsearch adds JVM tuning, cluster ops, and a separate observability story.

The agentic difference

For agents that already read and write Postgres data, pgvector keeps retrieval inside the same transactional and security boundary — RLS scopes vectors automatically, and joins enrich results without a second round trip. For agents whose retrieval quality depends on hybrid lexical+vector relevance across large or domain-heavy corpora, Elasticsearch's in-cluster inference and RRF deliver consistently better grounding than pgvector's hand-built hybrid.

When to pick which

  • Pick Elasticsearch when hybrid retrieval, in-cluster embeddings, or large-corpus scale are required.

  • Pick pgvector when the agent already lives in a Postgres-backed app and you want vectors inside the same database, backup, and auth model.

Last verified: 2026-06-10