Deploy and Master Meilisearch for Lightning‑Fast Full‑Text Search
This guide explains why Meilisearch is a lightweight alternative to Elasticsearch, walks through Docker‑based installation, demonstrates index creation, settings configuration, document CRUD operations, and various search queries, all with concrete curl commands and code examples.
Introduction
Meilisearch is a lightweight, fast full‑text search engine that can be deployed with minimal hardware. It provides sub‑50 ms response times, typo‑tolerance, language‑specific optimizations (e.g., Chinese), and a RESTful API.
Installation with Docker
Pull the official Docker image and run a container exposing port 7700. Example commands:
docker pull getmeili/meilisearch:v1.13
docker run -p 7700:7700 --name meilisearch \
-e MEILI_ENV='development' \
-v /mydata/meiliData:/meili_data \
-d getmeili/meilisearch:v1.13After the container starts, the Mini Dashboard is reachable at http://<em>host</em>:7700.
Creating an Index and Importing Documents
Meilisearch treats an index as a collection of JSON documents. First download a sample dataset (e.g., movies.json) and import it with curl:
curl -X POST '{{MEILISEARCH_URL}}/indexes/movies/documents?primaryKey=id' \
-H 'Content-Type: application/json' \
--data-binary @movies.jsonList all indexes:
curl -X GET '{{MEILISEARCH_URL}}/indexes'Delete an index:
curl -X DELETE '{{MEILISEARCH_URL}}/indexes/movies'Index Settings
Settings are defined via a JSON payload. To make title and release_date sortable and to enable filtering on genres and release_date:
curl -X PATCH '{{MEILISEARCH_URL}}/indexes/movies/settings' \
-H 'Content-Type: application/json' \
--data-binary '{
"sortableAttributes": ["title", "release_date"],
"filterableAttributes": ["genres", "release_date"]
}'Document Operations
Add a document:
curl -X POST '{{MEILISEARCH_URL}}/indexes/movies/documents' \
-H 'Content-Type: application/json' \
--data-binary '{
"id": 1,
"title": "Transformers Test",
"overview": "Young teenager, Sam Witwicky becomes involved in the ancient struggle...",
"genres": ["Adventure", "Science Fiction", "Action"],
"poster": "https://image.tmdb.org/t/p/w500/6eehp9I54syN3x753XMqjKz8M3F.jpg",
"release_date": 1182902400
}'Retrieve a document:
curl -X GET '{{MEILISEARCH_URL}}/indexes/movies/documents/1'Update a document (partial or full):
curl -X PUT '{{MEILISEARCH_URL}}/indexes/movies/documents' \
-H 'Content-Type: application/json' \
--data-binary '[{"id":1,"title":"Transformers Update"}]'Delete a document:
curl -X DELETE '{{MEILISEARCH_URL}}/indexes/movies/documents/1'Search Queries
Simple search:
curl -X POST '{{MEILISEARCH_URL}}/indexes/movies/search' \
-H 'Content-Type: application/json' \
--data-binary '{ "q": "Transformers" }'Paginated search (first 5 results):
curl -X POST '{{MEILISEARCH_URL}}/indexes/movies/search' \
-H 'Content-Type: application/json' \
--data-binary '{ "q": "Transformers", "offset": 0, "limit": 5 }'Sorted search (by release date descending):
curl -X POST '{{MEILISEARCH_URL}}/indexes/movies/search' \
-H 'Content-Type: application/json' \
--data-binary '{ "q": "Transformers", "offset": 0, "limit": 5, "sort": ["release_date:desc"] }'Filtered search (Action or Adventure genres):
curl -X POST '{{MEILISEARCH_URL}}/indexes/movies/search' \
-H 'Content-Type: application/json' \
--data-binary '{ "q": "Transformers", "offset": 0, "limit": 5, "sort": ["release_date:desc"], "filter": "genres = Action OR genres = Adventure" }'Project Repository
GitHub:
https://github.com/meilisearch/meilisearchSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Tech Enthusiast
Sharing computer programming language knowledge, focusing on Java fundamentals, data structures, related tools, Spring Cloud, IntelliJ IDEA... Book giveaways, red‑packet rewards and other perks await!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
