typesense

Fast, typo-tolerant open source search engine

Deploy typesense

typesense

railwayapp-templates/typesense

Just deployed

/data

Deploy and Host Typesense on Railway

Typesense is a fast, typo-tolerant search engine for building delightful search experiences. It's an open source alternative to Algolia and an easier-to-use alternative to Elasticsearch.

About Hosting Typesense

Hosting Typesense involves deploying a single binary search engine with no runtime dependencies that you can run with a single command. Typesense is simple to set up, integrate with, operate and scale. Built for blazing fast performance with low-latency searches under 50ms, it works with standard web protocols and requires public url access when deployed on Railway. Version upgrades are seamless - simply swap out the binary and restart Typesense.

Common Use Cases

  • E-commerce Product Search: Build fast, typo-tolerant search with faceting, filtering, and dynamic sorting capabilities. Features like "sort by price" and merchandising let you boost specific products to fixed positions in search results
  • Content Discovery: Implement semantic and hybrid search for articles, documentation, and media using vector search and built-in models like S-BERT and E-5, or integrate with OpenAI and PaLM APIs for out-of-the-box semantic experiences
  • Multi-tenant Applications: Create scoped search experiences using API keys that restrict access to specific records per tenant, with federated search across multiple collections in a single request
  • Location-based Services: Build geo search functionality to find and sort results around coordinates or within bounding boxes, perfect for store locators and local business discovery

Dependencies for Typesense Hosting

  • API Client Libraries: Language-specific Typesense clients with built-in retry strategies for reliable connections
  • Memory Requirements: Memory needs scale with dataset size (approximately 900mb for 2.2 million records, 14gb for 28 million records)
  • Processing Power: Sufficient server resources for indexing and handling concurrent search queries

Deployment Dependencies

Implementation Details

Key Features:

  • Typo Tolerance: Handles typographical errors elegantly out-of-the-box
  • Tunable Ranking: Easy to tailor search results to perfection with custom ranking algorithms
  • Faceting & Filtering: Drill down and refine results with dynamic filters
  • Grouping & Distinct: Group similar results together to show more variety in search results
  • Synonyms: Define words as equivalents so searching for one word returns results for defined synonyms
  • Vector Search: Index embeddings from machine learning models for similarity search, semantic search, visual search, and recommendations
  • Semantic/Hybrid Search: Automatically generate embeddings using built-in models or external APIs like OpenAI
  • Geo Search: Search and sort by results around coordinates or within bounding boxes
  • Federated Search: Search across multiple collections in a single HTTP request
  • Raft-based Clustering: Set up distributed clusters that are highly available

Typesense offers official API clients with smart retry strategies:

Community-contributed clients include:

Basic usage example:

const Typesense = require('typesense');

const client = new Typesense.Client({
  'nodes': [{
    'host': process.env.TYPESENSE_HOST,
    'port': process.env.TYPESENSE_PORT,
    'protocol': 'https'
  }],
  'apiKey': process.env.TYPESENSE_API_KEY,
  'connectionTimeoutSeconds': 2
});

// Create a collection with faceted fields
const schema = {
  'name': 'products',
  'fields': [
    {'name': 'title', 'type': 'string'},
    {'name': 'price', 'type': 'float'},
    {'name': 'category', 'type': 'string', 'facet': true},
    {'name': 'brand', 'type': 'string', 'facet': true},
    {'name': 'location', 'type': 'geopoint'}
  ]
};

await client.collections().create(schema);

// Search with typo tolerance, filtering, faceting, and geo search
const searchResults = await client
  .collections('products')
  .documents()
  .search({
    'q': 'runing shoes',  // Typo tolerance handles this automatically
    'query_by': 'title',
    'filter_by': 'price:[50..200] && category:footwear',
    'facet_by': 'brand,category',
    'sort_by': 'price:asc',
    'geo_location': '37.7749,-122.4194',  // San Francisco coordinates
    'geo_radius': '10 km'
  });

// Use synonyms for better search results
await client.collections('products').synonyms().upsert('footwear-synonyms', {
  'synonyms': ['shoes', 'sneakers', 'footwear', 'boots']
});

Framework Integrations Available: Laravel, Firebase, Gatsby, WordPress, WooCommerce, Symfony, InstantSearch, DocSearch, Docusaurus, and many more

Performance Benchmarks:

  • 2.2 million recipes: Uses 900mb memory, handles 104 concurrent queries per second with 11ms average response time
  • 28 million books: Uses 14gb memory, handles 46 concurrent queries per second with 28ms average response time
  • 3 million products: Handles 250 concurrent queries per second on an 8-processor 3-node high availability cluster

Why Deploy Typesense on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Typesense on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


Template Content

More templates in this category

View Template
Foundry Virtual Tabletop
A Self-Hosted & Modern Roleplaying Platform

View Template
(v1) Simple Medusa Backend
Deploy an ecommerce backend and admin using Medusa

View Template
peppermint
Docker-compose port for peppermint.sh