Replacing Algolia & Elastic Cloud: Self-Hosted Search with Meilisearch, Typesense & OpenSearch
Search is a core component of modern web applications, SaaS products, and e-commerce stores. However, managed search services like Algolia charge aggressive metered pricing ($0.50+ per 1,000 search requests and steep index record limits). On the other end, managed Elastic Cloud clusters typically start at $95/month and consume gigabytes of JVM memory before indexing a single document.
Fortunately, modern self-hosted search engines offer sub-50ms search-as-you-type performance, typo tolerance, multi-faceted filtering, and vector hybrid search—all deployable on an inexpensive $6 to $12/month VPS.
In this guide, we compare Meilisearch, Typesense, and OpenSearch, and provide production-ready Docker Compose configurations.
Engine Comparison Matrix
| Feature | Meilisearch | Typesense | OpenSearch / Elastic |
|---|---|---|---|
| Primary Architecture | Rust (LMDB memory-mapped) | C++ (In-memory + RocksDB) | Java / Lucene (Distributed cluster) |
| Search Latency (<100k docs) | < 10ms (Blazing) | < 10ms (Blazing) | 25-50ms |
| RAM Consumption | Moderate (Memory-mapped cache) | High (Full dataset kept in RAM) | Very High (JVM heap 2GB - 32GB) |
| Typo Tolerance & Ranking | ⭐⭐⭐⭐⭐ (Out-of-the-box perfect) | ⭐⭐⭐⭐⭐ (Configurable typo rules) | ⭐⭐⭐ (Requires custom tokenizers) |
| Vector & Hybrid Search | Native (Embedders & Auto-generation) | Native (Built-in ONNX / OpenAI models) | Native (k-NN plugin / neural search) |
| Multi-Node Clustering | Cloud-native / Enterprise | Raft Consensus (Built-in High Availability) | Native Sharding & Distributed Cluster |
| Best Used For | E-commerce, Docs, Apps (<5M docs) | Fast SaaS Search, Geo-search, High QPS | Big Data Logs, SIEM, massive datasets (>10M docs) |
Architectural Deep Dive
1. Meilisearch — Developer Experience & Instant Relevance
Meilisearch is written in Rust and is hyper-focused on instant search-as-you-type experiences.
- Why Choose Meilisearch: Default ranking rules (words, typo, proximity, attribute, exactness) work flawlessly without manual NLP tuning.
- Vector Search Support: Supports hybrid search combining BM25 keyword matching with dense vector embeddings directly from HuggingFace, OpenAI, or local Ollama endpoints.
- Resource Footprint: Uses LMDB, so indexes reside on disk and cache heavily in OS RAM.
2. Typesense — C++ In-Memory Speed & Native Clustering
Typesense is built in C++ specifically as an open-source alternative to Algolia.
- Why Choose Typesense: Holds the full index in RAM with RocksDB disk persistence, offering ultra-low search latency even under thousands of concurrent queries per second (QPS).
- Clustering: Includes native 3-node or 5-node Raft consensus clustering out-of-the-box without needing external orchestrators.
3. OpenSearch — Distributed Big Data Scale
OpenSearch (the Apache-2.0 fork of Elasticsearch maintained by AWS and the Linux Foundation) remains the industry standard for distributed text search across millions of large documents and log archives.
- Why Choose OpenSearch: Massive scalability, complex aggregations, distributed sharding, and deep plugin ecosystems.
- Caveat: High operational overhead. Requires careful JVM heap tuning and at least 4GB to 8GB of RAM.
Production Docker Compose: Meilisearch with Persistent Storage & Master Key Security
Here is a hardened docker-compose.yml for running Meilisearch in production behind Traefik or Caddy:
version: '3.8'
services:
meilisearch:
image: getmeili/meilisearch:v1.12
restart: unless-stopped
environment:
- MEILI_ENV=production
- MEILI_MASTER_KEY=${MEILI_MASTER_KEY:?Required}
- MEILI_NO_ANALYTICS=true
- MEILI_MAX_INDEXING_MEMORY=2Gb
- MEILI_MAX_INDEXING_THREADS=2
- MEILI_HTTP_PAYLOAD_SIZE_LIMIT=104857600 # 100MB batch upload cap
volumes:
- meili_data:/meili_data
ports:
- "127.0.0.1:7700:7700"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:7700/health"]
interval: 10s
timeout: 5s
retries: 5
networks:
- search_net
volumes:
meili_data:
networks:
search_net:
driver: bridge
Typesense Production Alternative
For teams requiring native in-memory caching and Raft clustering, here is the equivalent Typesense configuration:
version: '3.8'
services:
typesense:
image: typesense/typesense:27.1
restart: unless-stopped
environment:
- TYPESENSE_API_KEY=${TYPESENSE_API_KEY:?Required}
- TYPESENSE_DATA_DIR=/data
- TYPESENSE_ENABLE_CORS=true
volumes:
- typesense_data:/data
ports:
- "127.0.0.1:8108:8108"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8108/health"]
interval: 10s
timeout: 5s
retries: 5
networks:
- search_net
volumes:
typesense_data:
networks:
search_net:
driver: bridge
Production Security & Deployment Tips
- Never Expose the Master Key to Frontend Clients: Generate scoped Search-Only API keys with limited index access and expiration timestamps using the engine's Key Management API.
- Backups & Snapshots: Meilisearch and Typesense support scheduled automatic snapshot exports. Set up a simple cron container that dumps snapshots to an S3-compatible bucket (e.g. MinIO, Cloudflare R2, or Garage).
- RAM Sizing: For Typesense, ensure your VPS has at least 1.5x the RAM of your total uncompressed dataset. For Meilisearch, ensure fast NVMe storage for optimal memory-mapped file paging.
Which One Should You Choose?
- Choose Meilisearch for fast SaaS search, docs, mobile apps, and instant typo-tolerant search bars with minimal configuration.
- Choose Typesense for high-throughput e-commerce catalogs requiring sub-millisecond in-memory response times and built-in Raft clustering.
- Choose OpenSearch for complex distributed enterprise analytics, log indexing, and multi-terabyte search clusters.
Check out more comparisons, migration benchmarks, and production-tested architectures at SelfHostStack.
Top comments (0)