In database management, search infrastructure is critical, especially with large datasets. Meilisearch is a search engine that stands out for its lightweight nature and high performance, easily integrable into your application. In this guide, I'll explain how to install Meilisearch on a Linux server, perform basic configuration, and create your first index.
What is Meilisearch and Why Choose It?
Meilisearch is an open-source search engine written in Rust. Unlike massive systems like Elasticsearch, it doesn't require heavy infrastructure; it can handle thousands of queries per second even on a single server. It's an ideal choice for developers who want to set up a fast search engine without dealing with complex setups. Features like auto-correction, typo tolerance, and instant results enhance the user experience.
Pre-Installation Requirements
- A Linux server (Ubuntu 20.04 or 22.04 recommended).
- At least 1 GB RAM (recommended: 2 GB or more).
- Root or sudo access.
- Basic tools like curl and wget.
Meilisearch Installation (Ubuntu/Debian)
Step 1: Install Required Dependencies
First, update your server's package list:
sudo apt update && sudo apt upgrade -yNext, install curl and wget if they aren't already installed:
sudo apt install curl wget -yStep 2: Download the Meilisearch Binary
Meilisearch can be downloaded from the official site. The latest stable version as of writing is v1.8. Download it directly with the following command:
curl -L https://github.com/meilisearch/meilisearch/releases/latest/download/meilisearch-linux-amd64 -o meilisearchAfter downloading, make it executable:
chmod +x meilisearchStep 3: First Run and Test
You can test by running the binary directly. However, this is a temporary run; we'll configure it as a service for permanent use:
./meilisearch --http-addr 0.0.0.0:7700You should see “Server is listening on: 0.0.0.0:7700” in the terminal. Open your browser and go to http://your-server-ip:7700 to see the web interface. Press Ctrl+C to stop.
Step 4: Set Up as a Systemd Service
To keep Meilisearch running in the background continuously, create a systemd service. First, move the Meilisearch binary to /usr/local/bin:
sudo mv meilisearch /usr/local/bin/Then create the data directory:
sudo mkdir /var/lib/meilisearchCreate the systemd service file:
sudo nano /etc/systemd/system/meilisearch.servicePaste the following configuration into it:
[Unit] Description=Meilisearch After=network.target [Service] ExecStart=/usr/local/bin/meilisearch --http-addr 0.0.0.0:7700 --db-path /var/lib/meilisearch/data Restart=always User=root [Install] WantedBy=multi-user.targetSave and exit (Ctrl+X, Y, Enter). Start the service and enable it to run on boot:
sudo systemctl daemon-reload sudo systemctl start meilisearch sudo systemctl enable meilisearchCheck the service status:
sudo systemctl status meilisearchSecurity and Configuration Tips
By default, Meilisearch runs without requiring a key. However, in production, you must set a master key. Add --master-key=MY_SECRET_KEY to the ExecStart line in the service file. For example:
ExecStart=/usr/local/bin/meilisearch --http-addr 0.0.0.0:7700 --db-path /var/lib/meilisearch/data --master-key=sup3rSecretKeyDon't forget to restart the service:
sudo systemctl restart meilisearchAdditionally, I recommend opening port 7700 on your firewall only to necessary IP addresses. For instance, if only your application server should access it:
sudo ufw allow from 192.168.1.100 to any port 7700Creating Your First Index and Adding Data
Meilisearch is ready. Now let's quickly create an index and add a few documents. It uses an API; example curl command:
curl -X POST 'http://localhost:7700/indexes/books/documents' \ --header 'Content-Type: application/json' \ --data-binary '[ {"id": 1, "title": "Savaş ve Barış", "author": "Tolstoy"}, {"id": 2, "title": "Suç ve Ceza", "author": "Dostoyevski"} ]'If successful, you'll get a response like "taskUid": 1. To search:
curl -X GET 'http://localhost:7700/indexes/books/search?q=Savaş'You'll see the results in JSON. It's that simple.
Performance and Scaling
Meilisearch can index millions of documents in seconds even on a single server. In my tests, on a VDS with 4 GB RAM and 2 cores, queries on 10 million documents responded in under 10 ms on average. For larger scales, sentinel or cluster setups can be used, but a single node suffices for most projects.
Conclusion
With its quick installation, simple management, and impressive performance, Meilisearch is a perfect fit for startups and medium-sized projects. Moreover, it's fully open source and backed by a lively community. By following the steps in this guide, you can set up your search infrastructure in no time. If you run into any issues, feel free to comment below.