Meilisearch is a Rust search engine focused on typo-tolerant, instant-feel search out of the box — sane defaults, fast indexing, and a single binary. This article installs Meilisearch on Ubuntu 22.04 or 24.04 as a systemd service, sets the master key, fronts it with Nginx + TLS, and walks through indexing a sample document. Audience is operators bringing up Meilisearch for a product search, docs search, or marketplace use case.
How to verify
After the install, confirm Meilisearch responds and the master key is enforced:
systemctl status meilisearch
journalctl -u meilisearch -n 50 --no-pager
curl -s http://127.0.0.1:7700/health
curl -s http://127.0.0.1:7700/version
curl -s http://127.0.0.1:7700/keys
curl -s -H "Authorization: Bearer $MEILI_MASTER_KEY" http://127.0.0.1:7700/keys
A correctly secured install returns "missing_authorization_header" on the unauthenticated /keys call and the actual key list on the authenticated one.
What’s happening
Meilisearch is a single Rust binary backed by LMDB. There’s no JVM, no cluster mode in the open-source build (that’s a Cloud feature), and no schema language — you POST JSON documents and it figures out the searchable attributes. Out of the box it does typo tolerance via Levenshtein distance, prefix matching, and a ranking pipeline (words → typo → proximity → attribute → sort → exactness) that you can reorder per index.
The master key is the only credential at install time. It mints scoped API keys (search-only, admin, per-index). You should never use the master key from a client — issue a search-only key with restricted index access and rotate it on a schedule.
Storage is on disk under /var/lib/meilisearch/data.ms. There’s no replication in the open-source build; durability comes from snapshots and S3 backups.
The procedure
1. Install from the official binary release:
curl -fsSL https://install.meilisearch.com | sudo sh
sudo mv ./meilisearch /usr/local/bin/
sudo useradd -r -s /usr/sbin/nologin meilisearch
sudo mkdir -p /var/lib/meilisearch /etc/meilisearch
sudo chown -R meilisearch:meilisearch /var/lib/meilisearch
2. Generate a master key and write the config:
MEILI_MASTER_KEY=$(openssl rand -base64 48)
echo "$MEILI_MASTER_KEY" | sudo tee /etc/meilisearch/master-key.txt >/dev/null
sudo chmod 600 /etc/meilisearch/master-key.txt
sudo chown meilisearch:meilisearch /etc/meilisearch/master-key.txt
Drop a config file at /etc/meilisearch/config.toml:
db_path = "/var/lib/meilisearch/data.ms"
env = "production"
http_addr = "127.0.0.1:7700"
log_level = "INFO"
schedule_snapshot = 86400
snapshot_dir = "/var/lib/meilisearch/snapshots"
3. Create the systemd unit at /etc/systemd/system/meilisearch.service:
[Unit]
Description=Meilisearch
After=network.target
[Service]
Type=simple
User=meilisearch
Group=meilisearch
EnvironmentFile=/etc/meilisearch/env
ExecStart=/usr/local/bin/meilisearch --config-file-path /etc/meilisearch/config.toml
Restart=on-failure
RestartSec=5
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
And the environment file at /etc/meilisearch/env:
MEILI_MASTER_KEY=paste-the-key-here
chmod 600 it. Then enable and start:
sudo systemctl daemon-reload
sudo systemctl enable --now meilisearch
4. Mint a scoped search key for the frontend:
curl -X POST 'http://127.0.0.1:7700/keys' \
-H "Authorization: Bearer $MEILI_MASTER_KEY" \
-H 'Content-Type: application/json' \
-d '{
"description": "Search-only key for product index",
"actions": ["search"],
"indexes": ["products"],
"expiresAt": null
}'
Use that key in client code; the master key stays on the server.
5. Index a sample document:
curl -X POST 'http://127.0.0.1:7700/indexes/products/documents' \
-H "Authorization: Bearer $MEILI_MASTER_KEY" \
-H 'Content-Type: application/json' \
-d '[{"id":1,"name":"Lavender soap","category":"bath"},
{"id":2,"name":"Vetiver candle","category":"home"}]'
Then search:
curl -X POST 'http://127.0.0.1:7700/indexes/products/search' \
-H "Authorization: Bearer $SEARCH_KEY" \
-H 'Content-Type: application/json' \
-d '{"q":"lavandre"}'
lavandre is a typo — Meilisearch still finds the lavender soap.
6. Front with Nginx + TLS. Place a reverse proxy on 443:
server {
listen 443 ssl http2;
server_name search.example.com;
ssl_certificate /etc/letsencrypt/live/search.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/search.example.com/privkey.pem;
location / {
proxy_pass http://127.0.0.1:7700;
proxy_set_header Host $host;
proxy_read_timeout 30s;
}
}
Common pitfalls
- Master key shorter than 16 bytes — Meilisearch refuses to enter production mode. Always use a long random key (48 bytes from openssl).
- Index settings overwritten on full document update —
PUT /indexes/{uid}/documentsreplaces by primary key, but a settings update with empty arrays clears searchable attributes. Always PATCH settings. - No replication — the open-source build is single-node. Use snapshots and ship them off-box; a hot standby requires manual restore from snapshot.
- Synonyms are case-sensitive in config but normalized at search — confusion is common. Test with the analyzer endpoint.
- Default ranking rules don’t sort by sales/popularity — add a sortable attribute and put
sortahead ofattributein the ranking pipeline.
In the engagements we run, Meilisearch usually shows up as the product or docs search behind a Next.js or Rails front-end. The operational shape is small — single binary, snapshots to S3, Nginx + TLS in front, scoped API keys per client. See /en/services/managed-operations/ for how we run search alongside the rest of the application stack.