docker.recipes

Typesense

beginner

Fast open-source search engine optimized for instant search experiences.

Overview

Typesense is a modern, open-source search engine built from the ground up to deliver instant, typo-tolerant search experiences. Created as a developer-friendly alternative to complex solutions like Elasticsearch and expensive services like Algolia, Typesense focuses on simplicity without sacrificing performance. It provides sub-10ms search responses while handling common search challenges like typos, synonyms, and result ranking out of the box. This Docker configuration deploys a single Typesense node that exposes a RESTful JSON API for indexing documents and performing searches. The setup includes persistent data storage and configurable API key authentication, making it suitable for both development and production environments. Typesense excels at use cases requiring real-time search with minimal operational overhead. E-commerce platforms benefit from Typesense's instant product search with faceting and filtering capabilities, while content sites can implement fast site-wide search without complex setup. Developers appreciate the straightforward API design and built-in features like geo-search and vector similarity search, making it an excellent choice for teams wanting powerful search functionality without the complexity of managing Elasticsearch clusters.

Key Features

  • Typo tolerance with intelligent fuzzy matching and ranking
  • Sub-10ms search response times with instant-as-you-type results
  • Built-in faceting and filtering for complex search refinement
  • Geo-spatial search with distance-based sorting and filtering
  • Vector search capabilities for semantic similarity matching
  • Synonym management and result curation through pinning
  • Multi-tenant search with collection-based data isolation
  • RESTful JSON API with comprehensive search parameters

Common Use Cases

  • 1E-commerce product catalogs with instant search and filtering
  • 2Documentation sites requiring fast full-text search
  • 3SaaS applications needing embedded search functionality
  • 4Content management systems with real-time article discovery
  • 5Job boards with location-based and skill-based search
  • 6Real estate platforms combining text and geo-spatial search
  • 7Knowledge bases requiring typo-tolerant search across documents

Prerequisites

  • Docker and Docker Compose installed on the host system
  • Minimum 256MB RAM available, 1GB+ recommended for production
  • Port 8108 available on the host for API access
  • Basic understanding of RESTful APIs for search integration
  • Valid TYPESENSE_API_KEY environment variable configured
  • JSON data structure knowledge for document indexing

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:
3 image: typesense/typesense:latest
4 container_name: typesense
5 restart: unless-stopped
6 command: --data-dir /data --api-key=${TYPESENSE_API_KEY}
7 volumes:
8 - typesense_data:/data
9 ports:
10 - "8108:8108"
11 networks:
12 - typesense-network
13
14volumes:
15 typesense_data:
16
17networks:
18 typesense-network:
19 driver: bridge

.env Template

.env
1TYPESENSE_API_KEY=changeme-api-key

Usage Notes

  1. 1Docs: https://typesense.org/docs/
  2. 2API at http://localhost:8108 - RESTful JSON API
  3. 3Health check: curl http://localhost:8108/health
  4. 4Instant typo-tolerant search with sub-10ms responses
  5. 5Built-in geo-search, faceting, and multi-tenant support
  6. 6Excellent Algolia alternative - similar DX, self-hosted

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 typesense:
5 image: typesense/typesense:latest
6 container_name: typesense
7 restart: unless-stopped
8 command: --data-dir /data --api-key=${TYPESENSE_API_KEY}
9 volumes:
10 - typesense_data:/data
11 ports:
12 - "8108:8108"
13 networks:
14 - typesense-network
15
16volumes:
17 typesense_data:
18
19networks:
20 typesense-network:
21 driver: bridge
22EOF
23
24# 2. Create the .env file
25cat > .env << 'EOF'
26TYPESENSE_API_KEY=changeme-api-key
27EOF
28
29# 3. Start the services
30docker compose up -d
31
32# 4. View logs
33docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/typesense/run | bash

Troubleshooting

  • Container fails to start: Ensure TYPESENSE_API_KEY environment variable is set and not empty
  • API returns 401 Unauthorized: Verify the X-TYPESENSE-API-KEY header matches your configured API key
  • Search returns no results for valid queries: Check if documents are properly indexed and collection schema matches data structure
  • High memory usage during indexing: Reduce batch size when importing large datasets or increase container memory limits
  • Connection refused on port 8108: Confirm port mapping in docker-compose and check if firewall is blocking access
  • Data loss after container restart: Verify typesense_data volume is properly mounted and persistent

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

Ad Space