Typesense is a free, open-source search engine that's optimized for instant search-as-you-type experiences. Built in C++, it delivers sub-millisecond search results.
What Is Typesense?
Typesense is a typo-tolerant, blazing-fast search engine designed as an easier-to-use alternative to Elasticsearch and a free alternative to Algolia.
What makes it special:
- Sub-millisecond search latency
- Typo tolerance out of the box
- Tunable ranking and relevance
- Faceting and filtering
- Geo search
- Vector search (AI-powered semantic search)
- Scoped API keys (multi-tenancy)
- Single binary, no dependencies
- High availability with built-in replication
Quick Start
Install
# Docker
docker run -p 8108:8108 \
-v /tmp/typesense-data:/data \
typesense/typesense:27.1 \
--data-dir /data \
--api-key=your-api-key
# macOS
brew install typesense/tap/typesense-server
Create a Collection
curl "http://localhost:8108/collections" \
-X POST \
-H "X-TYPESENSE-API-KEY: your-api-key" \
-d '{
"name": "products",
"fields": [
{"name": "name", "type": "string"},
{"name": "price", "type": "float"},
{"name": "category", "type": "string", "facet": true},
{"name": "rating", "type": "float"}
],
"default_sorting_field": "rating"
}'
Add Documents
curl "http://localhost:8108/collections/products/documents" \
-X POST \
-H "X-TYPESENSE-API-KEY: your-api-key" \
-d '{"name": "Ergonomic Keyboard", "price": 89.99, "category": "Electronics", "rating": 4.8}'
Search
curl "http://localhost:8108/collections/products/documents/search?q=keybrd&query_by=name" \
-H "X-TYPESENSE-API-KEY: your-api-key"
Returns "Ergonomic Keyboard" despite the typo. In <1ms.
JavaScript SDK
import Typesense from "typesense";
const client = new Typesense.Client({
nodes: [{ host: "localhost", port: 8108, protocol: "http" }],
apiKey: "your-api-key"
});
// Search
const results = await client.collections("products").documents().search({
q: "keyboard",
query_by: "name",
filter_by: "price:<100",
sort_by: "rating:desc",
facet_by: "category"
});
Vector Search (AI-Powered)
Typesense supports semantic search with vector embeddings:
// Create collection with vector field
await client.collections().create({
name: "docs",
fields: [
{ name: "title", type: "string" },
{ name: "content", type: "string" },
{ name: "embedding", type: "float[]", num_dim: 384 }
]
});
// Search by meaning, not just keywords
const results = await client.collections("docs").documents().search({
q: "how to deploy containers",
query_by: "embedding",
prefix: false
});
Typesense vs Alternatives
| Feature | Elasticsearch | Algolia | Typesense |
|---|---|---|---|
| Latency | 10-100ms | <10ms | <1ms |
| Setup complexity | High | None (SaaS) | Low |
| Typo tolerance | Plugin | Built-in | Built-in |
| Vector search | Plugin | No | Built-in |
| Self-host | Yes | No | Yes |
| RAM usage | 2GB+ | N/A | 256MB+ |
| Free tier | Self-host | 10K req/mo | Unlimited |
| License | SSPL | Proprietary | GPL-3.0 |
InstantSearch UI
Typesense works with Algolia's InstantSearch.js UI components:
import instantsearch from "instantsearch.js";
import { searchBox, hits } from "instantsearch.js/es/widgets";
import TypesenseInstantSearchAdapter from "typesense-instantsearch-adapter";
const adapter = new TypesenseInstantSearchAdapter({
server: { nodes: [{ host: "localhost", port: 8108, protocol: "http" }], apiKey: "search-key" },
additionalSearchParameters: { query_by: "name" }
});
const search = instantsearch({ indexName: "products", searchClient: adapter.searchClient });
search.addWidgets([searchBox({ container: "#search" }), hits({ container: "#hits" })]);
search.start();
High Availability
# Start a 3-node cluster
typesense-server --data-dir /data --api-key=key --nodes /etc/typesense/nodes
Automatic leader election, data replication, and failover.
Who Uses Typesense?
With 21K+ GitHub stars:
- E-commerce platforms replacing Algolia
- Documentation sites
- Recipe and content search apps
- SaaS products with search features
Get Started
- Run Docker container (one command)
- Create a collection with schema
- Index your documents
- Search with typo tolerance in <1ms
No JVM. No cluster configuration. Just fast search.
Need data to index in your search engine? Check out my web scraping tools on Apify — extract structured data from any website. Custom solutions: spinov001@gmail.com
Top comments (0)