# Typesense Search Engine

> Typesense instant search with built-in typo tolerance and faceting.

- Category: Database Stacks
- Difficulty: beginner
- Components: typesense, typesense-dashboard
- Tags: typesense, search, full-text, algolia-alternative, instant-search
- Source: https://docker.recipes/databases/typesense-search

## Overview

Typesense is an open-source, typo-tolerant search engine built for instant search experiences. Created as a developer-friendly alternative to complex solutions like Elasticsearch and expensive services like Algolia, Typesense focuses on delivering sub-millisecond search latency with built-in typo tolerance, faceting, and filtering capabilities. Its simple REST API and straightforward configuration make it ideal for developers who need powerful search functionality without the operational overhead of traditional search engines.

This stack combines Typesense server with the community-built Typesense Dashboard, creating a complete search solution with visual management capabilities. The dashboard provides an intuitive interface for managing collections, indexing documents, and testing search queries, while the Typesense server handles all search operations with its high-performance C++ core. Together, they offer both programmatic API access and visual administration tools for comprehensive search implementation.

This combination is perfect for development teams building e-commerce platforms, content management systems, or any application requiring fast, intelligent search functionality. Startups benefit from the cost-effective alternative to hosted search services, while enterprises appreciate the self-hosted control and clustering capabilities. The visual dashboard makes it accessible to non-technical team members who need to manage search data, test queries, or configure search parameters without diving into API documentation.

## Features

- Sub-millisecond search latency with intelligent typo tolerance
- Built-in faceting and filtering for complex product catalogs
- Visual dashboard for collection management and query testing
- CORS-enabled API for direct browser integration
- Vector search capabilities for AI-powered semantic search
- Geo-search functionality for location-based filtering
- Synonym management and result curation features
- High availability clustering support for production deployments

## Use cases

- E-commerce product search with autocomplete and faceted navigation
- SaaS application search for user-generated content and documentation
- Real estate platforms requiring geo-search and property filtering
- Content management systems with full-text article and media search
- Developer documentation sites with instant code and API search
- Educational platforms searching courses, instructors, and learning materials
- Job board applications with skill-based and location filtering

## Prerequisites

- Minimum 1GB RAM for optimal Typesense performance with moderate datasets
- Ports 8108 and 8080 available for Typesense API and dashboard access
- Valid TYPESENSE_API_KEY environment variable for server authentication
- Basic understanding of REST APIs for integration and data indexing
- JSON knowledge for document structure and collection schema design

## docker-compose.yml

```yaml
services:
  typesense:
    image: typesense/typesense:0.25.1
    container_name: typesense
    environment:
      - TYPESENSE_DATA_DIR=/data
      - TYPESENSE_API_KEY=${TYPESENSE_API_KEY}
      - TYPESENSE_ENABLE_CORS=true
    volumes:
      - typesense_data:/data
    ports:
      - "8108:8108"
    networks:
      - typesense-network
    command: '--data-dir=/data --api-key=${TYPESENSE_API_KEY} --enable-cors'

  dashboard:
    image: bfritscher/typesense-dashboard:latest
    container_name: typesense-dashboard
    ports:
      - "8080:80"
    networks:
      - typesense-network

volumes:
  typesense_data:

networks:
  typesense-network:
    driver: bridge
```

## .env

```bash
# Typesense Search
TYPESENSE_API_KEY=your-api-key-here
```

## Usage notes

- API at http://localhost:8108
- Dashboard at http://localhost:8080
- Connect dashboard to localhost:8108
- Sub-millisecond search latency
- Built-in typo tolerance

## Troubleshooting

- Dashboard shows 'Connection failed' error: Verify Typesense is running on port 8108 and use 'typesense:8108' for internal Docker network connections
- Search queries return 401 Unauthorized: Check TYPESENSE_API_KEY environment variable matches between server and client requests
- Typesense container exits with 'permission denied' on /data: Ensure Docker has write permissions to the typesense_data volume mount point
- Search results missing expected documents: Verify collection schema matches indexed document structure and fields are marked as searchable
- High memory usage with large datasets: Increase container memory limits or implement data partitioning strategies for datasets over 1GB

