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.
<code>docker pull getmeili/meilisearch:v1.13</code> <code>docker run -p 7700:7700 --name meilisearch \
-e MEILI_ENV='development' \
-v /mydata/meiliData:/meili_data \
-d getmeili/meilisearch:v1.13</code>After 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.
<code>curl \
-X POST \
'{{MEILISEARCH_URL}}/indexes/movies/documents?primaryKey=id' \
-H 'Content-Type: application/json' \
--data-binary @movies.json</code>After importing, you can search for a term such as
Transformersin the Mini Dashboard.
List all indexes with:
<code>curl -X GET '{{MEILISEARCH_URL}}/indexes'</code>Delete an index with:
<code>curl -X DELETE '{{MEILISEARCH_URL}}/indexes/movies'</code>Settings Operations
Settings define search behavior, similar to a table schema.
Retrieve current settings:
<code>curl -X GET '{{MEILISEARCH_URL}}/indexes/movies/settings'</code>Make
titleand
release_datesortable, and
genresand
release_datefilterable:
<code>curl -X PATCH '{{MEILISEARCH_URL}}/indexes/movies/settings' \
-H 'Content-Type: application/json' \
--data-binary '{
"sortableAttributes": ["title","release_date"],
"filterableAttributes": ["genres","release_date"]
}'</code>Document Operations
Documents are analogous to rows in a database table.
Add a document:
<code>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
}'</code>Retrieve a document:
<code>curl -X GET '{{MEILISEARCH_URL}}/indexes/movies/documents/1'</code>Update a document:
<code>curl -X PUT '{{MEILISEARCH_URL}}/indexes/movies/documents' \
-H 'Content-Type: application/json' \
--data-binary '[{"id":1,"title":"Transformers Update"}]'</code>Delete a document:
<code>curl -X DELETE '{{MEILISEARCH_URL}}/indexes/movies/documents/1'</code>Data Search
Search data using Meilisearch’s API.
Simple search:
<code>curl -X POST '{{MEILISEARCH_URL}}/indexes/movies/search' \
-H 'Content-Type: application/json' \
--data-binary '{ "q": "Transformers" }'</code>Paginated search:
<code>curl -X POST '{{MEILISEARCH_URL}}/indexes/movies/search' \
-H 'Content-Type: application/json' \
--data-binary '{ "q": "Transformers","offset": 0,"limit": 5 }'</code>Sorted search:
<code>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"]}'</code>Filtered search:
<code>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"}'</code>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.
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.