Skip to navigationSkip to main contentSkip to footerScaleway DocsAsk our AI
Ask our AI

Deploying Meilisearch on a Scaleway Instance

meilisearch
search
full-text
instance

Meilisearch is an open-source search engine that provides instant and relevant search results from large collections of data. Meilisearch is particularly useful for applications that require fast and efficient search capabilities, such as e-commerce sites, documentation search, and any platform where users need to quickly find relevant information from a large dataset.

This tutorial shows you how to deploy a Meilisearch search engine on a Scaleway Instance.

Before you start

To complete the actions presented below, you must have:

Connecting to your Instance and starting Meilisearch

  1. Open a terminal and connect to your Instance using SSH. Replace <INSTANCE_IP> with your Instance's IP (Instances > Overview > Flexible IP > the first IP address that displays in the list).

    ssh root@<INSTANCE_IP>
    Tip

    If you are using an Instance with a Docker InstantApp, run docker -v to make sure that the Docker engine is already installed. The current Docker engine version should display.

  2. In the same terminal, generate a master key for Meilisearch. This key will secure your Meilisearch instance.

    export MEILI_MASTER_KEY=$(openssl rand -base64 16)
  3. Run the following command to display the master key:

    echo $MEILI_MASTER_KEY
    Important

    Copy and save your master key as you will need it in the next steps.

  4. Run the MeiliSearch container using Docker. This command sets up Meilisearch to store data persistently on the volume located at $(pwd)/meili_data:/meili_data on your Instance.

    docker run -d -p 7700:7700 -v $(pwd)/meili_data:/meili_data  -e $MEILI_MASTER_KEY getmeili/meilisearch:v1.9
  5. Check that the container is running:

    docker ps

    You should see an output similar to the following:

    CONTAINER ID   IMAGE                       COMMAND                  CREATED          STATUS          PORTS                                       NAMES
    0432254e4d64   getmeili/meilisearch:v1.9   "tini -- /bin/sh -c …"   56 minutes ago   Up 56 minutes   0.0.0.0:7700->7700/tcp, :::7700->7700/tcp   flamboyant_dewdney
    Tip

    You can stop the Meilisearch container using docker container stop <container_name>.

  6. Use the following command to check that Meilisearch is running.

    curl -X GET 'http://localhost:7700/version' -H 'Authorization: Bearer '$MEILI_MASTER_KEY

    You should see an output similar to the following:

    {
    "commitSha": "0df84bbba7db46680e83843dd6454257161a282f",
    "commitDate": "2024-06-27T12:00:00Z",
    "pkgVersion": "aaaaaa"
    }

Accessing Meilisearch remotely

  1. Open a new terminal and export your environment variables. Make sure that you replace {INSTANCE_PUBLIC_DNS} and {MEILI_MASTER_KEY} with your own variables.
    export INSTANCE_PUBLIC_DNS={INSTANCE_PUBLIC_DNS}
     export MEILI_MASTER_KEY={MEILI_MASTER_KEY}
    Your command should look like the following:
    export INSTANCE_PUBLIC_DNS=a3dc5b0e-5c5c-4ac4-91fb-1447b5c23b57.pub.instances.scw.cloud
    export MEILI_MASTER_KEY=LtRrsh68IdT2jKDH5DdXhA==
  2. Run the following command to access Meilisearch remotely:
    curl -X GET 'http://'$INSTANCE_PUBLIC_DNS':7700/version' -H 'Authorization: Bearer '$MEILI_MASTER_KEY
Tip

You can also open your browser at http://{INSTANCE_PUBLIC_DNS}:7700/health since you do not need an API key to access the /health endpoint.

If you have created your Instance within a Private Network or if you are using a specific security group configuration, you must allow TCP traffic on port 7700 for your Instance to access your Meilisearch container remotely. See our dedicated documentation on how to use security groups and how to configure a Public Gateway for more information.

Creating an index and adding data to it

  1. In the same terminal as the previous steps, paste the following command to create a new index named movies:

    curl -X POST 'http://'$INSTANCE_PUBLIC_DNS':7700/indexes' \
      -H 'Content-Type: application/json' \
      -H 'Authorization: Bearer '$MEILI_MASTER_KEY \
      --data-binary '{
        "uid": "movies",
        "primaryKey": "id"
      }'
  2. Add sample data to the movies index. In this case, we are adding 2 movies.

    curl -X POST 'http://'$INSTANCE_PUBLIC_DNS':7700/indexes/movies/documents' \
      -H 'Content-Type: application/json' \
      -H 'Authorization: Bearer '$MEILI_MASTER_KEY \
      --data-binary '[
        {
          "id": 1,
          "title": "The Enigma of Elysia",
          "overview": "In a world where magic and technology coexist, a mysterious artifact known as the Elysia Stone is stolen from the royal palace."
        },
        {
          "id": 2,
          "title": "A Shattered Mirror",
          "overview": "In a world where dreams are reflected in a magical mirror, a young man named Orion discovers that his reflection has been shattered."
        }
      ]'

    An output similar to the following should display:

    {"taskUid":1,"indexUid":"movies","status":"enqueued","type":"documentAdditionOrUpdate","enqueuedAt":"2024-07-24T12:32:54.678571608Z"}root@scw-lucid-satoshi:~#
  3. Search for the term mystery in the movies index:

    curl -X POST 'http://'$INSTANCE_PUBLIC_DNS':7700/indexes/movies/search' \
      -H 'Content-Type: application/json' \
      -H 'Authorization: Bearer '$MEILI_MASTER_KEY \
    --data-binary '{ "q": "mystery" }'

    Documents containing the term (or close semantic variations of the term) should display in the output:

    {"hits":[{"id":1,"title":"The Enigma of Elysia","overview":"In a world where magic and technology coexist, a mysterious artifact known as the Elysia Stone is stolen from the royal palace."}],"query":"mystery","processingTimeMs":4,"limit":20,"offset":0,"estimatedTotalHits":1}

Going further

Troubleshooting

If you encounter any issues, check that you meet all the requirements listed at the beginning of this page. Also, verify that your Instance accepts connections from your computer. To do so, you can configure security groups or a Public Gateway on the Private Network your Instance belongs to.

Questions?

Visit our Help Center and find the answers to your most frequent questions.

Visit Help Center
No Results