Adding search to your application is one of those decisions where the wrong choice costs months of rework. Elasticsearch dominates the enterprise, Meilisearch has emerged as the developer-friendly alternative, and PostgreSQL's built-in full-text search covers surprisingly many use cases. This comparison helps you pick the right search solution for your scale and requirements.
Quick Comparison
| Feature | Elasticsearch | Meilisearch | PostgreSQL FTS | Typesense |
| Type | Distributed search engine | Embedded search engine | Database built-in | Embedded search engine |
| Language | Java | Rust | C (PostgreSQL) | C++ |
| Setup Complexity | High (JVM tuning, cluster management) | Very Low (single binary, zero config) | None (already in PostgreSQL) | Very Low (single binary) |
| Typo Tolerance | Fuzzy queries (configurable) | Built-in, excellent (default) | None (pg_trgm extension for trigram) | Built-in, excellent (default) |
| Faceted Search | Excellent (aggregations) | Good (filters + facets) | Manual (COUNT + GROUP BY) | Good (filters + facets) |
| Relevance Tuning | Very High (BM25, custom scoring, boost) | Good (ranking rules, customizable) | Limited (ts_rank, ts_rank_cd) | Good (ranking rules) |
| Indexing Speed | ~10K docs/sec | ~100K docs/sec | ~5K docs/sec | ~150K docs/sec |
| Query Latency | 10-100ms | 1-10ms | 5-50ms | 1-5ms |
| Max Scale | Billions of documents | Millions of documents | Millions (depends on hardware) | Millions of documents |
| Operational Cost | High (dedicated cluster) | Low (single server) | None (same DB server) | Low (single server) |
| Best For | Enterprise, log analytics, massive scale | SaaS apps, developer-friendly search | Simple search, when you only have PostgreSQL | SaaS apps, instant search experiences |
When to Use What
| Scenario | Recommended Solution | Why |
| You just need basic keyword search in one table | PostgreSQL FTS | No new infrastructure, good enough for most simple searches |
| SaaS app, need typo-tolerant search, faceted filtering | Meilisearch or Typesense | Excellent developer experience, minimal ops, fast |
| Log analytics, SIEM, massive text corpus (1B+ docs) | Elasticsearch | Only option that scales to billions with aggregation |
| E-commerce product search with facets | Meilisearch or Typesense | Built-in facets, typo tolerance, instant search |
| You already run Elasticsearch for logging (ELK stack) | Elasticsearch | Use existing infrastructure, operational expertise already present |
| Minimum operational overhead, small team | Meilisearch | Single binary, zero config, auto-indexing |
PostgreSQL Full-Text Search: Getting Started
-- Enable FTS with a generated column + index
ALTER TABLE articles ADD COLUMN search_vector tsvector
GENERATED ALWAYS AS (
setweight(to_tsvector('english', coalesce(title, '')), 'A') ||
setweight(to_tsvector('english', coalesce(body, '')), 'B')
) STORED;
CREATE INDEX articles_search_idx ON articles USING GIN (search_vector);
-- Search with ranking
SELECT title, ts_rank(search_vector, query) AS rank
FROM articles, to_tsquery('english', 'postgresql & performance') query
WHERE search_vector @@ query
ORDER BY rank DESC
LIMIT 20;
-- Limitations to know:
-- No typo tolerance (use pg_trgm for fuzzy matching)
-- No faceted search (implement with COUNT + GROUP BY)
-- Relevance tuning is basic compared to dedicated search engines
Meilisearch vs Typesense: Head-to-Head
| Feature | Meilisearch | Typesense |
| API Style | REST, intuitive | REST, intuitive |
| Typo Tolerance | Excellent, automatic | Excellent, automatic |
| Indexing Speed | ~100K docs/sec | ~150K docs/sec |
| Memory Usage | Higher (requires more RAM) | Lower (more memory efficient) |
| Client Libraries | 35+ official SDKs | 20+ official SDKs |
| Self-Hosted | Free (open source) | Free (open source) |
| Cloud | Meilisearch Cloud | Typesense Cloud |
| Best For | Developer happiness, rapid integration | Instant search (sub-10ms), high throughput |
Bottom line: Start with PostgreSQL FTS if you only need basic keyword search — it is free, already running, and handles 80% of use cases. Move to Meilisearch or Typesense when you need typo tolerance, faceted search, or instant-search UX. Only reach for Elasticsearch when you have a dedicated ops team and need to scale to billions of documents or complex aggregations. See also: PostgreSQL Query Optimization and PostgreSQL vs MySQL vs SQLite.