Install Meilisearch and run on windows

2023-09-11 Posted in SearchRust

meilisearch is good search engine that is simple and very fast with a good rest api. If you want to run meilisearch on Windows, you have to compile the code, but it's very simple.

Step 1 Clone meilisearch from Github

git clone https://github.com/meilisearch/MeiliSearch

Step 2 Install the Rust tools

In order to compile the project you have to install Rust, you will find a get started guid here

Step 3 Install C++ dev tools from Visual Studio

You need c++ dev tools from visual studio make sure it is installed. Open the Visual Studio installer and select Desktop development with C++

Visual Studio Workloads

Step 4 Compile the project

Go to the folder where you cloned the repository and run the commands:

rustup update

cargo build --release

Step 5 Run the program

When it has finished compiling, go to the folder /target/release

Now you can run meilisearch it will generate a master key if you don't submit one ./meilisearch.exe

Meilisearch have several libraries for 10 different languages here is an example in C#

MeilisearchClient client = new MeilisearchClient("http://localhost:7700", "masterkey");

try
{
   index = await client.GetIndexAsync("Movies");
}
catch (Meilisearch.MeilisearchApiError ex)
{

   if (ex.Code == "index_not_found")
   {
       await client.CreateIndexAsync("Movies", "MovieId");

       index = await client.GetIndexAsync("Movies");
   }
}

var MovieItem = new Movie(){
   Name = "Apollo 11",
   Year = 2019,
   IMDB = "tt8760684"
};

await index!.AddDocumentsAsync(MovieItem, "objectId");


var results = await index.SearchAsync<Movie>("Apollo");