Typesense is the open-source search engine built for speed. Sub-millisecond typo-tolerant search, faceted filtering, geo search — self-hosted, free forever.
What Is Typesense?
Typesense is a fast, typo-tolerant search engine optimized for instant search experiences. Built in C++, it returns results in under 50ms.
Quick Start
# Docker
docker run -p 8108:8108 \
-v /tmp/typesense-data:/data \
typesense/typesense:latest \
--data-dir /data \
--api-key=your-api-key
Create Collection
curl -s -X POST 'http://localhost:8108/collections' \
-H 'X-TYPESENSE-API-KEY: your-api-key' \
-H 'Content-Type: application/json' \
-d '{
"name": "products",
"fields": [
{"name": "name", "type": "string"},
{"name": "description", "type": "string"},
{"name": "price", "type": "float"},
{"name": "category", "type": "string", "facet": true},
{"name": "rating", "type": "float"},
{"name": "in_stock", "type": "bool", "facet": true}
],
"default_sorting_field": "rating"
}'
Index Documents
curl -s -X POST 'http://localhost:8108/collections/products/documents/import?action=create' \
-H 'X-TYPESENSE-API-KEY: your-api-key' \
-H 'Content-Type: text/plain' \
-d '{"name":"MacBook Pro 16","description":"Apple laptop with M3 Max chip","price":2499,"category":"Laptops","rating":4.8,"in_stock":true}
{"name":"ThinkPad X1 Carbon","description":"Lenovo business ultrabook","price":1399,"category":"Laptops","rating":4.6,"in_stock":true}
{"name":"iPad Air","description":"Apple tablet with M2 chip","price":599,"category":"Tablets","rating":4.7,"in_stock":false}'
Search
# Typo-tolerant search
curl -s 'http://localhost:8108/collections/products/documents/search?q=macbok&query_by=name,description&sort_by=rating:desc' \
-H 'X-TYPESENSE-API-KEY: your-api-key' | jq '.hits[].document.name'
# "MacBook Pro 16" — finds it despite typo!
# Filtered + faceted
curl -s 'http://localhost:8108/collections/products/documents/search?q=*&filter_by=category:Laptops&&price:<2000&facet_by=category,in_stock&sort_by=price:asc' \
-H 'X-TYPESENSE-API-KEY: your-api-key'
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: 'laptop',
query_by: 'name,description',
filter_by: 'price:<2000 && in_stock:true',
sort_by: 'rating:desc',
per_page: 10,
})
console.log(`Found ${results.found} products in ${results.search_time_ms}ms`)
InstantSearch UI (React)
import { InstantSearch, SearchBox, Hits, RefinementList } from 'react-instantsearch'
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,description' },
})
function SearchPage() {
return (
<InstantSearch searchClient={adapter.searchClient} indexName="products">
<SearchBox />
<RefinementList attribute="category" />
<Hits hitComponent={({ hit }) => <div>{hit.name} — ${hit.price}</div>} />
</InstantSearch>
)
}
Typesense vs Alternatives
| Feature | Typesense | Meilisearch | Algolia |
|---|---|---|---|
| Speed | <1ms | <50ms | <20ms |
| RAM usage | Low | Low | N/A |
| Open source | Yes | Yes | No |
| Geo search | Yes | Yes | Yes |
| Facets | Yes | Yes | Yes |
| Free | Self-hosted | Self-hosted | 10K req |
Search through scraped web data? Scrapfly + Typesense = searchable web data. Email spinov001@gmail.com for scraping + search pipelines.
Top comments (0)