Meilisearch is an open-source, lightning-fast search engine that provides instant search-as-you-type experiences. With typo tolerance, faceted search, and a RESTful API, it integrates into any application in minutes.
What Is Meilisearch?
Meilisearch is a Rust-based search engine designed for end-user facing search. It returns results in under 50ms, handles typos, and supports multiple languages out of the box. Think Algolia, but open-source and self-hosted.
Key Features:
- Search in under 50ms
- Typo tolerance
- Faceted search and filtering
- Geo search
- Multi-language support
- Synonyms and stop words
- Tenant tokens (multi-tenancy)
- RESTful API
Quick Start
# Install and run
curl -L https://install.meilisearch.com | sh
./meilisearch --master-key="your-master-key"
# Or via Docker
docker run -d -p 7700:7700 -v meili_data:/meili_data \
getmeili/meilisearch:latest \
meilisearch --master-key="your-master-key"
Meilisearch API: Index and Search
import requests
MEILI = "http://localhost:7700"
HEADERS = {"Authorization": "Bearer your-master-key", "Content-Type": "application/json"}
# Create index and add documents
documents = [
{"id": 1, "title": "React Tutorial", "category": "frontend", "views": 15000},
{"id": 2, "title": "Docker for Beginners", "category": "devops", "views": 23000},
{"id": 3, "title": "Python Web Scraping Guide", "category": "backend", "views": 18000},
{"id": 4, "title": "Kubernetes Best Practices", "category": "devops", "views": 12000},
{"id": 5, "title": "TypeScript Advanced Types", "category": "frontend", "views": 9000}
]
requests.post(f"{MEILI}/indexes/articles/documents", headers=HEADERS, json=documents)
# Search (with typo tolerance!)
result = requests.post(f"{MEILI}/indexes/articles/search", headers=HEADERS, json={
"q": "kuberntes", # typo in 'kubernetes' - still finds it!
"limit": 10
}).json()
for hit in result["hits"]:
print(f"{hit['title']} ({hit['category']}) - {hit['views']} views")
# Faceted search
result = requests.post(f"{MEILI}/indexes/articles/search", headers=HEADERS, json={
"q": "",
"facets": ["category"],
"filter": "category = devops AND views > 10000",
"sort": ["views:desc"]
}).json()
print(f"Facets: {result['facetDistribution']}")
Settings Configuration
# Configure searchable and filterable attributes
requests.patch(f"{MEILI}/indexes/articles/settings", headers=HEADERS, json={
"searchableAttributes": ["title", "category"],
"filterableAttributes": ["category", "views"],
"sortableAttributes": ["views"],
"synonyms": {
"k8s": ["kubernetes"],
"js": ["javascript"],
"ts": ["typescript"]
},
"stopWords": ["the", "a", "an", "is", "for"]
})
Multi-Search
# Search multiple indexes at once
results = requests.post(f"{MEILI}/multi-search", headers=HEADERS, json={
"queries": [
{"indexUid": "articles", "q": "docker", "limit": 3},
{"indexUid": "tutorials", "q": "docker", "limit": 3}
]
}).json()
Python SDK
import meilisearch
client = meilisearch.Client("http://localhost:7700", "your-master-key")
index = client.index("articles")
# Add documents
index.add_documents(documents)
# Search
results = index.search("react tutorial", {"limit": 5, "attributesToHighlight": ["title"]})
for hit in results["hits"]:
print(hit["_formatted"]["title"]) # Highlighted matches
Resources
- Meilisearch Docs
- Meilisearch GitHub — 48K+ stars
- API Reference
Need to scrape web data for your search engine? Check out my web scraping tools on Apify — production-ready actors for Reddit, Google Maps, and more. Questions? Email me at spinov001@gmail.com
Top comments (0)