#sdk #search #meilisearch


Rust wrapper for the MeiliSearch API. MeiliSearch is a powerful, fast, open-source, easy to use and deploy search engine.

8 unstable releases (3 breaking)

0.4.0 Nov 4, 2020
0.3.0 Aug 18, 2020
0.2.0 Jul 28, 2020
0.1.4 Jun 24, 2020
0.1.3 May 18, 2020

#76 in Database implementations

Download history 25/week @ 2020-08-09 27/week @ 2020-08-16 147/week @ 2020-08-23 44/week @ 2020-08-30 79/week @ 2020-09-06 29/week @ 2020-09-13 11/week @ 2020-09-20 187/week @ 2020-09-27 70/week @ 2020-10-04 192/week @ 2020-10-11 275/week @ 2020-10-18 96/week @ 2020-10-25 81/week @ 2020-11-01 122/week @ 2020-11-08 51/week @ 2020-11-15 78/week @ 2020-11-22

406 downloads per month

MIT license

1.5K SLoC


MeiliSearch Rust SDK

MeiliSearch | Documentation | Website | Blog | Twitter | FAQ

crates.io Tests License Slack Bors enabled

⚡ The MeiliSearch API client written for Rust 🦀

MeiliSearch Rust is the MeiliSearch API client for Rust developers. MeiliSearch is a powerful, fast, open-source, easy to use and deploy search engine. Both searching and indexing are highly customizable. Features such as typo-tolerance, filters, facets, and synonyms are provided out-of-the-box.

Table of Contents

📖 Documentation

See our Documentation or our API References.

🔧 Installation

To use meilisearch-sdk, add this to your Cargo.toml:

meilisearch-sdk = "0.4.0"

The following optional dependencies may also be useful:

tokio = { version = "0.2", features = ["macros"] }
serde = { version = "1.0", features = ["derive"] }

Since this crate is async, you have to run your program in the tokio runtime. When targetting Wasm, the browser will replace tokio.

Using this crate is possible without serde, but a lot of features require serde.

Run a MeiliSearch Instance

This crate requires a MeiliSearch server to run.

There are many easy ways to download and run a MeiliSearch instance.

For example, if you use Docker:

$ docker pull getmeili/meilisearch:latest # Fetch the latest version of MeiliSearch image from Docker Hub
$ docker run -it --rm -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --master-key=masterKey

NB: you can also download MeiliSearch from Homebrew or APT.

🚀 Getting Started

use meilisearch_sdk::{document::*, client::*, search::*};
use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize, Debug)]
struct Book {
    book_id: usize,
    title: String,

// That trait is required to make a struct usable by an index
impl Document for Book {
    type UIDType = usize;

    fn get_uid(&self) -> &Self::UIDType {

async fn main() {
    // Create a client (without sending any request so that can't fail)
    let client = Client::new("http://localhost:7700", "masterKey");

    // Get the index called "books"
    let books = client.get_or_create("books").await.unwrap();

    // Add some books in the index
        Book{book_id: 123,  title: String::from("Pride and Prejudice")},
        Book{book_id: 456,  title: String::from("Le Petit Prince")},
        Book{book_id: 1,    title: String::from("Alice In Wonderland")},
        Book{book_id: 1344, title: String::from("The Hobbit")},
        Book{book_id: 4,    title: String::from("Harry Potter and the Half-Blood Prince")},
        Book{book_id: 42,   title: String::from("The Hitchhiker's Guide to the Galaxy")},
    ], Some("book_id")).await.unwrap();

    // Query books (note that there is a typo)
    println!("{:?}", books.search().with_query("harry pottre").execute::<Book>().await.unwrap().hits);


[Book { book_id: 4, title: "Harry Potter and the Half-Blood Prince" }]

🌐 Running in the Browser with WASM

This crate fully supports WASM.

The only difference between the WASM and the native version is that the native version has one more variant (Error::Http) in the Error enum. That should not matter so much but we could add this variant in WASM too.

However, making a program intended to run in a web browser requires a very different design than a CLI program. To see an example of a simple Rust web app using MeiliSearch, see the tutorial (not available yet).

WARNING: meilisearch-sdk will panic if no Window is available (ex: Web extension).

🤖 Compatibility with MeiliSearch

This package only guarantees the compatibility with the version v0.16.0 of MeiliSearch.

⚙️ Development Workflow and Contributing

Any new contribution is more than welcome in this project!

If you want to know more about the development workflow or want to contribute, please visit our contributing guidelines for detailed instructions!

MeiliSearch provides and maintains many SDKs and Integration tools like this one. We want to provide everyone with an amazing search experience for any kind of project. If you want to contribute, make suggestions, or just know what's going on right now, visit us in the integration-guides repository.


~121K SLoC