Install MeiliSearch on Ubuntu 20.04

Install MeiliSearch on Ubuntu 20.04

MeiliSearch is an open-source search engine written in the Rust programming language. This search engine provides customizable search and indexing, understands typos, supports full-text search, synonyms, and offers other features.

This tutorial shows how to install MeiliSearch on Ubuntu 20.04.

Install MeiliSearch

Add the MeiliSearch repository:

echo "deb [trusted=yes] /" | sudo tee /etc/apt/sources.list.d/meilisearch.list

Update the package lists:

sudo apt update

Run the following command to install MeiliSearch:

sudo apt install -y meilisearch-http

When installation is completed, we can check MeiliSearch version:

meilisearch --version

Run MeiliSearch as a service

Now we need to configure systemd in order to run MeiliSearch as a service. So create a systemd unit file:

sudo nano /etc/systemd/system/meilisearch.service

Copy the following content to the file:

Description=MeiliSearch search engine

ExecStart=/usr/bin/meilisearch --http-addr --env production --master-key pwd123


Change value for --master-key option. It specifies master key which is used to access or create documents, indexes, or change configuration via API. Save and close file.

Note that binds MeiliSearch to all network interfaces. It accepts connections from any IPv4 address.

Now start MeiliSearch service:

sudo service meilisearch start

You can use the following command to make sure that MeiliSearch service is running:

sudo service meilisearch status

Also you can stop or restart the service:

sudo service meilisearch stop
sudo service meilisearch restart

To enable MeiliSearch to start on boot, execute the following command:

sudo systemctl enable meilisearch

Testing MeiliSearch

Download movies dataset:

curl -Lo movies.json

Send POST request to index data:

curl -X POST --data-binary @movies.json --header 'X-Meili-API-Key: pwd123'

Don't forget to change key and IP address of your machine.

Now send GET request to search movies:

curl --header 'X-Meili-API-Key: pwd123'

MeiliSearch will return response in JSON format.

  "hits": [
      "id": "315635",
      "title": "Spider-Man: Homecoming",
      "poster": "https://...",
      "overview": "...",
      "release_date": 1499216400
  "nbHits": 11,
  "exhaustiveNbHits": false,
  "query": "spiderman",
  "limit": 20,
  "offset": 0,
  "processingTimeMs": 3

Uninstall MeiliSearch

If you want to completely remove the MeiliSearch, stop the service and remove a systemd unit file.

sudo service meilisearch stop
sudo systemctl disable meilisearch
sudo rm -rf /etc/systemd/system/meilisearch.service
sudo systemctl daemon-reload
sudo systemctl reset-failed

Uninstall MeiliSearch:

sudo apt purge --autoremove -y meilisearch-http

Remove repository:

sudo rm -rf /etc/apt/sources.list.d/meilisearch.list

Leave a Comment

Cancel reply

Your email address will not be published.