|
1 | | -//! MeiliSearch-sdk is an async client for [MeiliSearch](https://www.meilisearch.com/) written in Rust. |
2 | | -//! [MeiliSearch](https://www.meilisearch.com/) is a powerful, fast, open-source, easy to use and deploy search engine. |
3 | | -//! Both searching and indexing are highly customizable. |
4 | | -//! Features such as typo-tolerance, filters, and synonyms are provided out-of-the-box. |
| 1 | +//! # 🔧 Installation |
5 | 2 | //! |
6 | | -//! ## Table of Contents |
7 | | -//! - [🔧 Installation](#-installation) |
8 | | -//! - [🚀 Getting started](#-getting-started) |
9 | | -//! - [🌐 Running in the browser with WASM](#-running-in-the-browser-with-wasm) |
10 | | -//! - [🤖 Compatibility with MeiliSearch](#-compatibility-with-meilisearch) |
| 3 | +//! To use `meilisearch-sdk`, add this to your `Cargo.toml`: |
11 | 4 | //! |
12 | | -//! # 🔧 Installation |
| 5 | +//! ```toml |
| 6 | +//! [dependencies] |
| 7 | +//! meilisearch-sdk = "0.2.0" |
| 8 | +//! ``` |
13 | 9 | //! |
14 | | -//! This crate requires a MeiliSearch server to run. See [here](https://docs.meilisearch.com/guides/advanced_guides/installation.html#download-and-launch) to install and run MeiliSearch. |
| 10 | +//! The following optional dependencies may also be useful: |
15 | 11 | //! |
16 | | -//! Then, put `meilisearch-sdk = "0.1"` in your Cargo.toml, as usual. |
| 12 | +//! ```toml |
| 13 | +//! tokio = { version = "0.2", features = ["macros"] } |
| 14 | +//! serde = { version = "1.0", features = ["derive"] } |
| 15 | +//! ``` |
17 | 16 | //! |
18 | | -//! Since this crate is async, you have to run your program in the tokio runtime (cf the example below). You will need `tokio = { version = "0.2", features=["macros"] }` in your Cargo.toml. When targetting Wasm, the browser will replace tokio. |
| 17 | +//! Since this crate is async, you have to run your program in the [tokio](https://crates.io/crates/tokio) runtime. When targetting Wasm, the browser will replace tokio. |
19 | 18 | //! |
20 | 19 | //! Using this crate is possible without [serde](https://crates.io/crates/serde), but a lot of features require serde. |
21 | | -//! Add `serde = {version="1.0", features=["derive"]}` in your Cargo.toml. |
22 | 20 | //! |
23 | | -//! # 🚀 Getting Started |
| 21 | +//! ## Run a MeiliSearch Instance |
| 22 | +//! |
| 23 | +//! This crate requires a MeiliSearch server to run. |
| 24 | +//! |
| 25 | +//! There are many easy ways to [download and run a MeiliSearch instance](https://docs.meilisearch.com/guides/advanced_guides/installation.html#download-and-launch). |
| 26 | +//! |
| 27 | +//! For example, if you use Docker: |
| 28 | +//! ```bash |
| 29 | +//! $ docker pull getmeili/meilisearch:latest # Fetch the latest version of MeiliSearch image from Docker Hub |
| 30 | +//! $ docker run -it --rm -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --master-key=masterKey |
| 31 | +//! ``` |
| 32 | +//! |
| 33 | +//! NB: you can also download MeiliSearch from **Homebrew** or **APT**. |
24 | 34 | //! |
25 | | -//! Here is a quickstart for a search request (please follow the [installation](#-installation) steps before) |
| 35 | +//! # 🚀 Getting Started |
26 | 36 | //! |
27 | | -//! ```rust |
28 | | -//! use meilisearch_sdk::{document::*, indexes::*, client::*, search::*}; |
| 37 | +//! ``` |
| 38 | +//! use meilisearch_sdk::{document::*, client::*, search::*}; |
29 | 39 | //! use serde::{Serialize, Deserialize}; |
30 | 40 | //! |
31 | 41 | //! #[derive(Serialize, Deserialize, Debug)] |
|
49 | 59 | //! let client = Client::new("http://localhost:7700", "masterKey"); |
50 | 60 | //! |
51 | 61 | //! // Get the index called "books" |
52 | | -//! let mut books = client.get_or_create("books").await.unwrap(); |
| 62 | +//! let books = client.get_or_create("books").await.unwrap(); |
53 | 63 | //! |
54 | 64 | //! // Add some books in the index |
55 | 65 | //! books.add_documents(&[ |
|
73 | 83 | //! [Book { book_id: 4, title: "Harry Potter and the Half-Blood Prince" }] |
74 | 84 | //! ``` |
75 | 85 | //! |
76 | | -//! # 🌐 Running in the browser with WASM |
| 86 | +//! ## 🌐 Running in the Browser with WASM |
77 | 87 | //! |
78 | | -//! 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. |
79 | | -//! 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)](). |
| 88 | +//! This crate fully supports WASM. |
80 | 89 | //! |
81 | | -//! WARNING: `meilisearch-sdk` will panic if no Window is available (ex: Web extension). |
82 | | -//! |
83 | | -//! # 🤖 Compatibility with MeiliSearch |
| 90 | +//! 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. |
84 | 91 | //! |
85 | | -//! This crate is currently supporting MeiliSearch v11.0 and will be maintained. |
| 92 | +//! 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)](). |
86 | 93 | //! |
87 | | -//! # Running the tests |
88 | | -//! |
89 | | -//! All the tests are documentation tests. |
90 | | -//! Since they are all making operations on the MeiliSearch server, running all the tests simultaneously would cause panics. |
91 | | -//! To run the tests one by one, run `cargo test -- --test-threads=1`. |
| 94 | +//! WARNING: `meilisearch-sdk` will panic if no Window is available (ex: Web extension). |
92 | 95 |
|
93 | 96 | /// Module containing the Client struct. |
94 | 97 | pub mod client; |
|
0 commit comments