# Getting Started

This quick tour will help you get started with MeiliSearch in only a few steps.

# Download and launch

First of all, let's download and run MeiliSearch.

curl -L https://install.meilisearch.com | sh
./meilisearch

You should see the following response:

888b     d888          d8b 888 d8b  .d8888b.                                    888
8888b   d8888          Y8P 888 Y8P d88P  Y88b                                   888
88888b.d88888              888     Y88b.                                        888
888Y88888P888  .d88b.  888 888 888  "Y888b.    .d88b.   8888b.  888d888 .d8888b 88888b.
888 Y888P 888 d8P  Y8b 888 888 888     "Y88b. d8P  Y8b     "88b 888P"  d88P"    888 "88b
888  Y8P  888 88888888 888 888 888       "888 88888888 .d888888 888    888      888  888
888   "   888 Y8b.     888 888 888 Y88b  d88P Y8b.     888  888 888    Y88b.    888  888
888       888  "Y8888  888 888 888  "Y8888P"   "Y8888  "Y888888 888     "Y8888P 888  888

Database path:       "./data.ms"
Server listening on: "127.0.0.1:7700"

You can download & run MeiliSearch in many different ways (i.e: docker, apt, homebrew, ...).

Environment variables and options can be set before and on launch to configure MeiliSearch. Amongst all the options, you can use the master key and the port options.

# Communicate with MeiliSearch

Now that your MeiliSearch server is up and running, you should be able to communicate with it.

Communication to the server is done through a RESTful API or one of our SDKs.

# Add Documents

To add documents to MeiliSearch you must provide:

  • Documents in the form of an array of JSON objects.
  • An index name (uid). An index is where the documents are stored.

If the index does not exist, MeiliSearch creates it when you first add documents.

To be processed, all documents must share one common which will serve as for the document. Values in that field must always be unique.

{
  "id": "123",
  "title": "Superman"
}

The primary key is id, the document's unique identifier is 123.

There are several ways to let MeiliSearch know what the primary key is. The easiest one is to have an that contains the string id in a case-insensitive manner.

Below is an example to showcase how to add documents to an index called movies using the following test dataset: movies.json (opens new window).

API references

# Checking updates

Most actions in MeiliSearch are asynchronous, including the document addition process.

Asynchronous actions return a JSON object that contains only an updateId attribute. This is a successful response, indicating that the operation has been taken into account, but may not have been executed yet.

You can check the status of the operation via the updateId and the get update status route. Checking the update status of an operation is never mandatory, but can prove useful in tracing the origin of errors or unexpected behavior.

See our guide on asynchronous updates or the updates API reference for more information.

Now that your documents have been ingested into MeiliSearch, you are able to search them.

MeiliSearch offers many parameters that you can play with to refine your search or change the format of the returned documents. However, by default, the search is already relevant.

The search engine is now aware of your documents and can serve those via an HTTP server.

MeiliSearch response:

{
  "hits": [
    {
      "id": "29751",
      "title": "Batman Unmasked: The Psychology of the Dark Knight",
      "poster": "https://image.tmdb.org/t/p/w1280/jjHu128XLARc2k4cJrblAvZe0HE.jpg",
      "overview": "Delve into the world of Batman and the vigilante justice tha",
      "release_date": "2008-07-15"
    },
    {
      "id": "471474",
      "title": "Batman: Gotham by Gaslight",
      "poster": "https://image.tmdb.org/t/p/w1280/7souLi5zqQCnpZVghaXv0Wowi0y.jpg",
      "overview": "ve Victorian Age Gotham City, Batman begins his war on crime",
      "release_date": "2018-01-12"
    }
    ...
  ],
  "offset": 0,
  "limit": 20,
  "processingTimeMs": 2,
  "query": "botman"
}

API references

# Web Interface

We also deliver an out-of-the-box web interface in which you can test MeiliSearch interactively.

To do so, open your web browser and enter MeiliSearch address (in our case: http://127.0.0.1:7700) into the browser address bar.
This will lead you to a web page with a search bar that will allow you to search in the selected index.



# Integrate with Your Project

The only step missing now is adding the search bar to your project. The easiest way of achieving this is to use instant-meilisearch (opens new window): a developer tool that generates all the search components needed to start searching.

Instant MeiliSearch (opens new window) works on common front-end environments, such as JavaScript (opens new window), React (opens new window), and Vue.js (opens new window).

instant-meilisearch uses InstantSearch (opens new window) an open-source library that generates everything you need from a search interface.

# Let's Try!

  • Create an html file, for example, index.html.
  • Open it in a text editor (e.g. Notepad, Sublime Text, Visual Studio Code).
  • Copy-paste any of the code examples below and save the file.
  • Open index.html in your browser (double click on it in your folder).

We use browser builds for ease of integration. It is possible to do this with npm or yarn. Please refer to instant-meilisearch (opens new window) for documentation.

You should now have a MeiliSearch database and a working front-end search interface πŸš€πŸ”₯ Check out What’s Next to continue your MeiliSearch journey.