Why Choose Meilisearch?
When building websites or applications, search functionality is almost a must-have. But when it comes to search engines, many people’s first thought is Elasticsearch. Honestly, Elasticsearch is powerful, but it has obvious drawbacks:
- High resource usage: Requires at least 1GB+ of RAM, which is a heavy burden for small VPS instances
- Complex deployment: Needs a JVM runtime and involves complicated configuration
- High operational cost: Cluster management and index tuning require professional knowledge
- Not cheap: Even the open-source version can be expensive to run on cloud infrastructure
Meilisearch is an open-source search engine written in Rust, with a core philosophy: make search simple, and give everyone their own search engine. Compared to Elasticsearch, it offers significant advantages:
| Feature | Meilisearch | Elasticsearch |
|---|---|---|
| Memory Usage | ~50MB (idle) | ~1GB+ |
| Deployment | Single binary / Docker | JVM + complex config |
| Learning Curve | Very low, intuitive API | Steep |
| Search Speed | Millisecond-level | Millisecond-level |
| Chinese Support | Built-in tokenizer | Requires plugin setup |
| Resource Requirements | Runs on 512MB RAM | Recommend 2GB+ |
| Operational Complexity | Near zero | High |
Core Features
1. Lightning-Fast Search
Built with Rust, Meilisearch fully leverages memory mapping and SIMD instruction set optimizations. Even with millions of documents, it can return search results in under 10 milliseconds.
2. Out-of-the-Box User Experience
- Typo tolerance: Automatically corrects user input typos
- Faceted search: Supports multi-dimensional filtering and sorting
- Multi-language support: Built-in tokenizers for 20+ languages, including Chinese
- Vector search: Supports semantic search (Meilisearch v0.28+)
3. Minimalist API Design
Meilisearch’s API is designed to be intuitive — almost all operations can be completed via HTTP requests, without the need for complex client libraries.
Environment Setup
System Requirements
- Operating System: Ubuntu 22.04 / 24.04 or Debian 12
- Memory: Minimum 512MB (1GB+ recommended)
- Disk: At least 5GB available space
- Docker: For containerized deployment (recommended)
Initialize Environment
# Update system
sudo apt update && sudo apt upgrade -y
# Install Docker
curl -fsSL https://get.docker.com | sudo sh
# Add current user to docker group
sudo usermod -aG docker $USER
newgrp docker
# Verify Docker installation
docker --version
Deploying Meilisearch
Method 1: Docker Deployment (Recommended)
# Create data persistence directory
mkdir -p ~/meilisearch/data
# Start Meilisearch container
docker run -d \
--name meilisearch \
-p 7700:7700 \
-v ~/meilisearch/data:/meili_data \
-e MEILI_MASTER_KEY=myMasterKey123 \
-e MEILI_NO_ANALYTICS=true \
-e MEILI_ENV=production \
meilisearch/meilisearch:latest
# Check running status
docker ps | grep meilisearch
docker logs -f meilisearch
Method 2: Direct Binary Download
# Download Meilisearch
curl -L https://meilisearch.com/install.sh | bash
# Start the service
./meilisearch --master-key myMasterKey123 --no-analytics
Configure Reverse Proxy (Optional)
For security, it’s recommended to expose Meilisearch through an Nginx reverse proxy:
server {
listen 443 ssl;
server_name search.yourdomain.com;
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
location / {
proxy_pass http://127.0.0.1:7700;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Basic Usage Guide
1. Create Index and Import Data
The core concept in Meilisearch is the Index, similar to a table in a database.
# Create an index and import data
curl -X POST 'http://localhost:7700/indexes/products/documents' \
--header 'Authorization: Bearer myMasterKey123' \
--header 'Content-Type: application/json' \
--data-binary @'products.json'
products.json example:
[
{
"id": 1,
"name": "Mechanical Keyboard",
"category": "Electronics",
"price": 299,
"description": "RGB backlit mechanical keyboard with Cherry switches"
},
{
"id": 2,
"name": "Wireless Mouse",
"category": "Electronics",
"price": 89,
"description": "Bluetooth wireless mouse with silent design"
},
{
"id": 3,
"name": "Monitor Stand",
"category": "Accessories",
"price": 159,
"description": "Adjustable angle monitor stand, aluminum alloy"
}
]
2. Perform Search
# Basic search
curl 'http://localhost:7700/indexes/products/search' \
--header 'Authorization: Bearer myMasterKey123' \
--header 'Content-Type: application/json' \
--data-binary '{"q": "keyboard"}'
# Search result
# {
# "hits": [
# {
# "id": 1,
# "name": "Mechanical Keyboard",
# "category": "Electronics",
# "price": 299,
# "description": "RGB backlit mechanical keyboard with Cherry switches"
# }
# ],
# "query": "keyboard",
# "offset": 0,
# "limit": 20,
# "processingTimeMs": 1
# }
3. Configure Searchable Attributes
Optimizing search experience starts with correctly configuring searchable fields:
# Set searchable and sortable attributes
curl -X PATCH 'http://localhost:7700/indexes/products' \
--header 'Authorization: Bearer myMasterKey123' \
--header 'Content-Type: application/json' \
--data-binary '{
"searchableAttributes": ["name", "description", "category"],
"sortableAttributes": ["price"],
"rankingRules": [
"words",
"typo",
"proximity",
"attribute",
"sort",
"exactness"
]
}'
Advanced Features
1. Chinese Tokenizer Configuration
Meilisearch has built-in support for Chinese, but for optimal results, you can customize the dictionary:
# Set Chinese dictionary
curl -X PATCH 'http://localhost:7700/indexes/products' \
--header 'Authorization: Bearer myMasterKey123' \
--header 'Content-Type: application/json' \
--data-binary '{
"dictionary": ["中文", "专业术语"]
}'
2. Faceted Search
Facets allow users to filter search results across multiple dimensions:
# Search with facets
curl 'http://localhost:7700/indexes/products/search' \
--header 'Authorization: Bearer myMasterKey123' \
--header 'Content-Type: application/json' \
--data-binary '{
"q": "monitor",
"facets": ["category", "price"]
}'
3. Vector Search (Semantic Search)
Meilisearch v0.28+ supports vector search for semantic-level queries:
# Enable vector search
curl -X PATCH 'http://localhost:7700/indexes/products' \
--header 'Authorization: Bearer myMasterKey123' \
--header 'Content-Type: application/json' \
--data-binary '{
"vectorStore": true
}'
# Use vector search
curl 'http://localhost:7700/indexes/products/search' \
--header 'Authorization: Bearer myMasterKey123' \
--header 'Content-Type: application/json' \
--data-binary '{
"q": "computer peripherals",
"vector": [0.1, 0.2, 0.3, ...]
}'
4. Data Backup and Restore
# Create a backup
curl -X POST 'http://localhost:7700/backups' \
--header 'Authorization: Bearer myMasterKey123'
# List backups
curl 'http://localhost:7700/backups' \
--header 'Authorization: Bearer myMasterKey123'
# Restore a backup
curl -X POST 'http://localhost:7700/backups/20240101-120000' \
--header 'Authorization: Bearer myMasterKey123'
Frontend Integration
1. Vue.js Integration Example
<template>
<div class="search-container">
<input v-model="query" @input="search" placeholder="Search..." />
<ul v-if="results.length">
<li v-for="item in results" :key="item.id">
{{ item.name }} - ${{ item.price }}
</li>
</ul>
</div>
</template>
<script setup>
import { ref } from 'vue'
const query = ref('')
const results = ref([])
const search = async () => {
const res = await fetch('http://localhost:7700/indexes/products/search', {
method: 'POST',
headers: {
'Authorization': 'Bearer myMasterKey123',
'Content-Type': 'application/json'
},
body: JSON.stringify({ q: query.value })
})
const data = await res.json()
results.value = data.hits
}
</script>
2. Next.js API Integration
// app/api/search/route.ts
export async function POST(request: Request) {
const { query } = await request.json()
const res = await fetch('http://localhost:7700/indexes/products/search', {
method: 'POST',
headers: {
'Authorization': 'Bearer myMasterKey123',
'Content-Type': 'application/json'
},
body: JSON.stringify({ q: query })
})
const data = await res.json()
return Response.json(data)
}
Performance Optimization Tips
1. Reasonably Set Index Fields
- Only set the fields you need as
searchableAttributes - Set fields used for sorting as
sortableAttributes - Regularly clean up unused indexes
2. Monitor Resource Usage
# Check Meilisearch resource usage
docker stats meilisearch
# Check search performance
curl 'http://localhost:7700/stats' \
--header 'Authorization: Bearer myMasterKey123'
3. Use Redis Caching
For high-frequency searches, add a Redis cache layer in front of Meilisearch:
# Install Redis
sudo apt install redis-server -y
sudo systemctl enable redis-server
sudo systemctl start redis-server
Frequently Asked Questions
Q1: Can Meilisearch replace Elasticsearch?
For small to medium projects (under 10 million documents), Meilisearch can完全 replace Elasticsearch. But for large-scale data scenarios, Elasticsearch’s distributed capabilities remain irreplaceable.
Q2: How is Chinese search quality?
Meilisearch has built-in Chinese tokenization support. For domain-specific terminology, customize the dictionary for better results.
Q3: How to ensure data security?
- Always set
MASTER_KEYfor authentication - Use reverse proxy with SSL encryption
- Regularly backup data
- Restrict access with IP whitelisting
Q4: What are Meilisearch’s limitations?
- No distributed deployment support (single-node architecture)
- Performance lags behind Elasticsearch at massive data scale
- Smaller ecosystem with fewer community plugins
Summary
Meilisearch, with its minimal deployment, ultra-low resource usage, and blazing-fast search speed, has become the ideal choice for self-hosted search scenarios. Whether it’s a personal blog, a small e-commerce platform, or an internal knowledge base, Meilisearch delivers an excellent search experience.
For VPS users on a budget, choosing Meilisearch over Elasticsearch is a smart move — you get outstanding search capabilities while saving significant resource costs.
Action item: Deploy your first Meilisearch instance today and experience the power of millisecond-level search!
