Master Fast Full‑Text Search with Meilisearch: A Hands‑On Docker Tutorial
Learn how to set up the lightweight Meilisearch engine using Docker, explore its rapid instant‑search features, and perform index, settings, document, and query operations via RESTful API and curl commands, all illustrated with step‑by‑step examples and screenshots.
Introduction
Meilisearch is a lightweight search engine that supports a RESTful search API and has already earned over 50k+star on GitHub. Its goal is to provide a fast and accurate search experience for every user.
Fast search: results in under 50 ms
Instant search: results appear as you type
Smart typo‑tolerance
Comprehensive language support, especially Chinese
Highly customizable indexing and search behavior
RESTful API support
SDKs for Java, JavaScript, Go, Python, etc.
Installation
Deploy Meilisearch with Docker for quick setup.
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, access the Mini Dashboard at http://localhost:7700.
Usage
Index Operations
In Meilisearch, an index is a collection of documents, similar to a table in MySQL.
Download the official demo dataset from the Meilisearch documentation.
Upload the data to a server and import it with curl.
Import documents via curl:
curl \
-X POST '{{MEILISEARCH_URL}}/indexes/movies/documents?primaryKey=id' \
-H 'Content-Type: application/json' \
--data-binary @movies.jsonSearch in the Mini Dashboard, e.g., type Transformers.
List all indexes:
curl \
-X GET '{{MEILISEARCH_URL}}/indexes'Delete an index:
curl \
-X DELETE '{{MEILISEARCH_URL}}/indexes/movies'Settings Operations
Settings are a JSON object that defines search behavior, similar to a table schema.
Query current settings:
curl \
-X GET '{{MEILISEARCH_URL}}/indexes/movies/settings'Modify settings to make title and release_date sortable, and genres and release_date filterable:
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 ...",
"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:
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
Simple search for "Transformers":
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 for 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"}'Conclusion
Meilisearch delivers instant, low‑configuration full‑text search with speeds far exceeding many traditional solutions, making it a practical alternative to Elasticsearch for many projects.
Signed-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.
Su San Talks Tech
Su San, former staff at several leading tech companies, is a top creator on Juejin and a premium creator on CSDN, and runs the free coding practice site www.susan.net.cn.
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.
