Typesense: Fast, Typo-Tolerant, Open Source Search Engine

Summary
Typesense is a blazing-fast, typo-tolerant, open-source search engine built in C++. It offers a delightful search experience, serving as an easier-to-use alternative to Elasticsearch and an open-source option to Algolia and Pinecone. With features like vector search, semantic search, and built-in RAG, it's designed for high performance and developer happiness.
Repository Info
Tags
Click on any tag to explore related repositories
Introduction
Typesense is a fast, typo-tolerant search engine designed for building delightful search experiences. Positioned as an open-source alternative to Algolia and Pinecone, and an easier-to-use option compared to Elasticsearch, it's meticulously architected in C++ for low-latency instant searches. Typesense empowers developers to create powerful search functionalities with ease, handling typographical errors out-of-the-box and supporting advanced features like vector search and semantic search.
You can see Typesense in action with several live demos, including searching large datasets of songs, books, recipes, and even implementing geo-search and semantic search experiences.
Installation
Typesense offers flexible installation options to get you started quickly:
- Binary Packages: Download pre-built binary packages for Linux (x86_64 & arm64) and Mac (x86_64) directly from the official website. Download Typesense
- Docker Image: Run Typesense using its official Docker image, providing a convenient way to deploy. Typesense Docker Hub
- Typesense Cloud: For a managed experience, spin up a dedicated cluster with Typesense Cloud. Typesense Cloud
To quickly start the Typesense server via Docker, use the following command:
docker run -p 8108:8108 -v/tmp/data:/data typesense/typesense:29.0 --data-dir /data --api-key=Hu52dwsas2AdxdE
Examples
Here's a quick example using the Python client to demonstrate how to create a collection, index a document, and search it with Typesense.
First, install the Python client:
pip install typesense
Next, initialize the client and create a companies collection:
import typesense
client = typesense.Client({
'api_key': 'Hu52dwsas2AdxdE',
'nodes': [{
'host': 'localhost',
'port': '8108',
'protocol': 'http'
}],
'connection_timeout_seconds': 2
})
create_response = client.collections.create({
"name": "companies",
"fields": [
{"name": "company_name", "type": "string" },
{"name": "num_employees", "type": "int32" },
{"name": "country", "type": "string", "facet": True }
],
"default_sorting_field": "num_employees"
})
Now, add a document to the collection:
document = {
"id": "124",
"company_name": "Stark Industries",
"num_employees": 5215,
"country": "USA"
}
client.collections['companies'].documents.create(document)
Finally, search for the document. Notice how Typesense handles typos out-of-the-box:
search_parameters = {
'q' : 'stork',
'query_by' : 'company_name',
'filter_by' : 'num_employees:>100',
'sort_by' : 'num_employees:desc'
}
client.collections['companies'].documents.search(search_parameters)
Why Use Typesense?
Typesense stands out for several compelling reasons, making it an excellent choice for modern search needs:
- Blazing Fast Performance: Built in C++, Typesense is meticulously optimized for low-latency instant searches, typically under 50ms. Benchmarks show it handling high concurrency, for example, 104 concurrent search queries per second on a 2.2 million recipe dataset with an average processing time of 11ms. It can scale to tens of millions of records with impressive speed.
- Comprehensive Feature Set: Beyond basic search, Typesense offers advanced capabilities including:
- Typo Tolerance: Handles typographical errors elegantly.
- Vector Search & Semantic Search: Index embeddings from ML models for similarity, semantic, and visual search. It can also automatically generate embeddings for conversational search and built-in RAG.
- Geo Search: Search and sort results by geographical location.
- Faceting & Filtering: Powerful tools for refining search results.
- Grouping & Distinct: Group similar results for better variety.
- JOINs & Synonyms: Model SQL-like relationships and define word equivalences.
- Raft-based Clustering: For highly available, distributed setups.
- No Runtime Dependencies: A single, lightweight binary simplifies deployment and operation.
- Developer Experience: Typesense prioritizes developer happiness with a simple setup, clean, well-documented API, clear semantics, and smart defaults that work well out-of-the-box, reducing the need for extensive tuning.
- Open Source & Cost-Effective: As an open-source project under the GPL-3.0 license, Typesense offers a powerful alternative to proprietary solutions like Algolia, allowing you to run it on your own infrastructure without per-record or per-search operation costs. Its lean in-memory data structures also contribute to efficient resource usage.
- Strong Community & Support: Typesense boasts a vibrant Slack community, active GitHub issue tracking, and offers paid support options for those requiring guaranteed SLAs and prioritized assistance.
Links
Explore Typesense further with these official resources:
- Official Website: https://typesense.org
- Documentation: https://typesense.org/docs/
- GitHub Repository: https://github.com/typesense/typesense
- Roadmap: https://typesense.link/roadmap
- Slack Community: https://typesense.link/slack-community
- Twitter: https://twitter.com/typesense
- API Clients: https://github.com/typesense/typesense#api-clients