Boost Your App with Meilisearch: Fast, Lightweight Search Engine Tutorial
This guide introduces Meilisearch, a lightweight, fast search engine with RESTful API, covering its features, Docker installation, index and settings management, document operations, and advanced search queries, while also showcasing a real‑world SpringBoot‑Vue e‑commerce project that integrates Meilisearch for instant, accurate results.
Introduction
Meilisearch is a lightweight search engine that provides a RESTful search API and has already earned over 50k stars on GitHub. Its goal is to deliver a fast and precise 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 search and indexing
RESTful API support
SDKs for Java, JavaScript, Go, Python and more
Below is a screenshot showing Meilisearch’s instant search speed.
Installation
Deploy Meilisearch conveniently with Docker.
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://192.168.3.101:7700.
Index Operations
Indexes in Meilisearch are analogous to tables in MySQL.
Download the official demo dataset from Meilisearch’s documentation.
Upload the dataset to your server and import it with curl.
curl \
-X POST \
'{{MEILISEARCH_URL}}/indexes/movies/documents?primaryKey=id' \
-H 'Content-Type: application/json' \
--data-binary @movies.jsonAfter importing, you can search for a term such as Transformers in the Mini Dashboard.
List all indexes with: curl -X GET '{{MEILISEARCH_URL}}/indexes' Delete an index with:
curl -X DELETE '{{MEILISEARCH_URL}}/indexes/movies'Settings Operations
Settings define search behavior, similar to a table schema.
Retrieve current settings:
curl -X GET '{{MEILISEARCH_URL}}/indexes/movies/settings'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
Documents are analogous to rows in a database table.
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 between two extraterrestrial factions of transforming robots...",
"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'Data Search
Search data using Meilisearch’s API.
Simple search:
curl -X POST '{{MEILISEARCH_URL}}/indexes/movies/search' \
-H 'Content-Type: application/json' \
--data-binary '{ "q": "Transformers" }'Paginated search:
curl -X POST '{{MEILISEARCH_URL}}/indexes/movies/search' \
-H 'Content-Type: application/json' \
--data-binary '{ "q": "Transformers","offset": 0,"limit": 5 }'Sorted search:
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:
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 provides a low‑configuration, high‑performance alternative to Elasticsearch, delivering instant search results with minimal setup. Give it a try to experience fast, accurate search in your applications.
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.
macrozheng
Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.
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.
