Typesense Search Cluster
High-performance search engine with typo tolerance, geo-search, and multi-node clustering.
Overview
Typesense is an open-source, typo-tolerant search engine built for instant search experiences with sub-millisecond response times. Originally created as a developer-friendly alternative to Elasticsearch and commercial solutions like Algolia, Typesense excels at full-text search, faceted filtering, and geo-spatial queries while maintaining simplicity in configuration and operation. Unlike traditional search engines that require complex mapping and tuning, Typesense automatically handles typo tolerance and relevance scoring out of the box.
This clustered deployment combines a three-node Typesense cluster with comprehensive monitoring through Prometheus and Grafana, fronted by NGINX for load balancing and high availability. The multi-node setup ensures zero-downtime operations during maintenance, automatic failover capabilities, and horizontal scaling for high-traffic applications. Prometheus scrapes metrics from all Typesense nodes to track search performance, query latency, and cluster health, while Grafana provides visual dashboards for monitoring search analytics and system performance.
E-commerce platforms, content management systems, and data-driven applications requiring instant search capabilities will benefit most from this stack. Organizations transitioning from Elasticsearch seeking simpler operations, or those evaluating Algolia alternatives for cost optimization, will find this configuration particularly valuable. The clustering approach makes it suitable for production environments serving thousands of concurrent search requests while maintaining sub-50ms query response times.
Key Features
- Three-node Typesense cluster with automatic leader election and data replication
- Built-in typo tolerance with configurable fuzzy matching algorithms
- Geo-spatial search capabilities for location-based filtering and sorting
- Vector search support for semantic similarity and recommendation engines
- Real-time search analytics and performance metrics via Prometheus integration
- Dynamic faceting with automatic field detection and filtering options
- NGINX load balancer with health checks and automatic failover routing
- Grafana dashboards for monitoring search query patterns and cluster performance
Common Use Cases
- 1E-commerce product catalogs with real-time inventory search and faceted filtering
- 2Content management systems requiring instant article and document discovery
- 3SaaS applications needing embedded search functionality with typo tolerance
- 4Data exploration platforms for large datasets with complex filtering requirements
- 5Job boards and marketplace platforms with location-based search capabilities
- 6Documentation sites requiring fast, accurate search across technical content
- 7Multi-tenant applications where search performance affects user experience
Prerequisites
- Minimum 4GB RAM available (1GB+ per Typesense node plus monitoring stack)
- Docker Engine 20.10+ with Docker Compose v2 support
- Available ports 3000, 8108, and 9090 for web interfaces
- Understanding of JSON document structure for search data indexing
- Basic knowledge of PromQL for custom Prometheus queries and alerting
- Familiarity with search concepts like facets, filters, and relevance scoring
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 typesense-1: 3 image: typesense/typesense:latest4 command: --data-dir /data --api-key=${TYPESENSE_API_KEY} --nodes=/etc/typesense/nodes --peering-address=typesense-15 volumes: 6 - ts1_data:/data7 - ./nodes:/etc/typesense/nodes:ro8 networks: 9 - typesense-net10 restart: unless-stopped1112 typesense-2: 13 image: typesense/typesense:latest14 command: --data-dir /data --api-key=${TYPESENSE_API_KEY} --nodes=/etc/typesense/nodes --peering-address=typesense-215 volumes: 16 - ts2_data:/data17 - ./nodes:/etc/typesense/nodes:ro18 networks: 19 - typesense-net20 restart: unless-stopped2122 typesense-3: 23 image: typesense/typesense:latest24 command: --data-dir /data --api-key=${TYPESENSE_API_KEY} --nodes=/etc/typesense/nodes --peering-address=typesense-325 volumes: 26 - ts3_data:/data27 - ./nodes:/etc/typesense/nodes:ro28 networks: 29 - typesense-net30 restart: unless-stopped3132 nginx: 33 image: nginx:alpine34 ports: 35 - "8108:8108"36 volumes: 37 - ./nginx.conf:/etc/nginx/nginx.conf:ro38 depends_on: 39 - typesense-140 - typesense-241 - typesense-342 networks: 43 - typesense-net44 restart: unless-stopped4546 prometheus: 47 image: prom/prometheus:latest48 ports: 49 - "9090:9090"50 volumes: 51 - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro52 - prometheus_data:/prometheus53 networks: 54 - typesense-net55 restart: unless-stopped5657 grafana: 58 image: grafana/grafana:latest59 ports: 60 - "3000:3000"61 environment: 62 GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD}63 volumes: 64 - grafana_data:/var/lib/grafana65 networks: 66 - typesense-net67 restart: unless-stopped6869volumes: 70 ts1_data: 71 ts2_data: 72 ts3_data: 73 prometheus_data: 74 grafana_data: 7576networks: 77 typesense-net: 78 driver: bridge.env Template
.env
1# Typesense API Key2TYPESENSE_API_KEY=your_secure_api_key_here34# Grafana5GRAFANA_PASSWORD=secure_grafana_passwordUsage Notes
- 1Search API at http://localhost:8108
- 23-node cluster for high availability
- 3Supports geo-search and vector search
- 4Import Grafana dashboard for monitoring
Individual Services(6 services)
Copy individual services to mix and match with your existing compose files.
typesense-1
typesense-1:
image: typesense/typesense:latest
command: "--data-dir /data --api-key=${TYPESENSE_API_KEY} --nodes=/etc/typesense/nodes --peering-address=typesense-1"
volumes:
- ts1_data:/data
- ./nodes:/etc/typesense/nodes:ro
networks:
- typesense-net
restart: unless-stopped
typesense-2
typesense-2:
image: typesense/typesense:latest
command: "--data-dir /data --api-key=${TYPESENSE_API_KEY} --nodes=/etc/typesense/nodes --peering-address=typesense-2"
volumes:
- ts2_data:/data
- ./nodes:/etc/typesense/nodes:ro
networks:
- typesense-net
restart: unless-stopped
typesense-3
typesense-3:
image: typesense/typesense:latest
command: "--data-dir /data --api-key=${TYPESENSE_API_KEY} --nodes=/etc/typesense/nodes --peering-address=typesense-3"
volumes:
- ts3_data:/data
- ./nodes:/etc/typesense/nodes:ro
networks:
- typesense-net
restart: unless-stopped
nginx
nginx:
image: nginx:alpine
ports:
- "8108:8108"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- typesense-1
- typesense-2
- typesense-3
networks:
- typesense-net
restart: unless-stopped
prometheus
prometheus:
image: prom/prometheus:latest
ports:
- "9090:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus_data:/prometheus
networks:
- typesense-net
restart: unless-stopped
grafana
grafana:
image: grafana/grafana:latest
ports:
- "3000:3000"
environment:
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD}
volumes:
- grafana_data:/var/lib/grafana
networks:
- typesense-net
restart: unless-stopped
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 typesense-1:5 image: typesense/typesense:latest6 command: --data-dir /data --api-key=${TYPESENSE_API_KEY} --nodes=/etc/typesense/nodes --peering-address=typesense-17 volumes:8 - ts1_data:/data9 - ./nodes:/etc/typesense/nodes:ro10 networks:11 - typesense-net12 restart: unless-stopped1314 typesense-2:15 image: typesense/typesense:latest16 command: --data-dir /data --api-key=${TYPESENSE_API_KEY} --nodes=/etc/typesense/nodes --peering-address=typesense-217 volumes:18 - ts2_data:/data19 - ./nodes:/etc/typesense/nodes:ro20 networks:21 - typesense-net22 restart: unless-stopped2324 typesense-3:25 image: typesense/typesense:latest26 command: --data-dir /data --api-key=${TYPESENSE_API_KEY} --nodes=/etc/typesense/nodes --peering-address=typesense-327 volumes:28 - ts3_data:/data29 - ./nodes:/etc/typesense/nodes:ro30 networks:31 - typesense-net32 restart: unless-stopped3334 nginx:35 image: nginx:alpine36 ports:37 - "8108:8108"38 volumes:39 - ./nginx.conf:/etc/nginx/nginx.conf:ro40 depends_on:41 - typesense-142 - typesense-243 - typesense-344 networks:45 - typesense-net46 restart: unless-stopped4748 prometheus:49 image: prom/prometheus:latest50 ports:51 - "9090:9090"52 volumes:53 - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro54 - prometheus_data:/prometheus55 networks:56 - typesense-net57 restart: unless-stopped5859 grafana:60 image: grafana/grafana:latest61 ports:62 - "3000:3000"63 environment:64 GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD}65 volumes:66 - grafana_data:/var/lib/grafana67 networks:68 - typesense-net69 restart: unless-stopped7071volumes:72 ts1_data:73 ts2_data:74 ts3_data:75 prometheus_data:76 grafana_data:7778networks:79 typesense-net:80 driver: bridge81EOF8283# 2. Create the .env file84cat > .env << 'EOF'85# Typesense API Key86TYPESENSE_API_KEY=your_secure_api_key_here8788# Grafana89GRAFANA_PASSWORD=secure_grafana_password90EOF9192# 3. Start the services93docker compose up -d9495# 4. View logs96docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/typesense-search-stack/run | bashTroubleshooting
- Cluster formation fails with 'peer not found' errors: Verify all nodes can resolve each other's hostnames and check the nodes configuration file contains correct addresses
- Search queries return 'TYPESENSE_API_KEY_INCORRECT' errors: Ensure the TYPESENSE_API_KEY environment variable matches across all cluster nodes and client requests
- High memory usage on Typesense nodes: Reduce the number of indexed fields, implement field-level indexing controls, or increase available memory allocation per container
- NGINX returns 502 Bad Gateway errors: Check Typesense container health status and verify the upstream configuration matches the actual container names and ports
- Prometheus scraping fails with connection refused: Confirm Typesense nodes are exposing metrics on the correct port and Prometheus targets configuration is accurate
- Grafana dashboards show no data: Verify Prometheus data source configuration and ensure metrics retention period covers the query time range
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Components
typesenseprometheusgrafananginx
Tags
#search#typesense#full-text#geo-search#cluster
Category
Database StacksAd Space
Shortcuts: C CopyF FavoriteD Download