Skip to content

Commit 588322f

Browse files
committed
Update template and run script
1 parent 9015e46 commit 588322f

File tree

2 files changed

+4
-178
lines changed

2 files changed

+4
-178
lines changed

README.md

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
## Table of Contents <!-- omit in TOC -->
3636

3737
- [📖 Documentation](#-documentation)
38-
- [⚡ Supercharge your Meilisearch experience](#-supercharge-your-meilisearch-experience)
3938
- [🔧 Installation](#-installation)
4039
- [🚀 Getting started](#-getting-started)
4140
- [🌐 Running in the Browser with WASM](#-running-in-the-browser-with-wasm)
@@ -48,10 +47,6 @@ This readme contains all the documentation you need to start using this Meilisea
4847

4948
For general information on how to use Meilisearch—such as our API reference, tutorials, guides, and in-depth articles—refer to our [main documentation website](https://www.meilisearch.com/docs).
5049

51-
## ⚡ Supercharge your Meilisearch experience
52-
53-
Say goodbye to server deployment and manual updates with [Meilisearch Cloud](https://www.meilisearch.com/cloud?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-rust). Get started with a 14-day free trial! No credit card required.
54-
5550
## 🔧 Installation
5651

5752
To use `meilisearch-sdk`, add this to your `Cargo.toml`:
@@ -73,23 +68,11 @@ You can enable the `sync` feature to make most structs `Sync`. It may be a bit s
7368

7469
Using this crate is possible without [serde](https://crates.io/crates/serde), but a lot of features require serde.
7570

76-
### Run a Meilisearch Instance <!-- omit in TOC -->
77-
78-
This crate requires a Meilisearch server to run.
79-
80-
There are many easy ways to [download and run a Meilisearch instance](https://www.meilisearch.com/docs/learn/getting_started/installation).
71+
### Run Meilisearch <!-- omit in toc -->
8172

82-
For example,using the `curl` command in [your Terminal](https://itconnect.uw.edu/learn/workshops/online-tutorials/web-publishing/what-is-a-terminal/):
83-
84-
```bash
85-
# Install Meilisearch
86-
curl -L https://install.meilisearch.com | sh
87-
88-
# Launch Meilisearch
89-
./meilisearch --master-key=masterKey
90-
```
73+
⚡️ **Launch, scale, and streamline in minutes with Meilisearch Cloud**—no maintenance, no commitment, cancel anytime. [Try it free now](https://cloud.meilisearch.com/login?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-rust).
9174

92-
NB: you can also download Meilisearch from **Homebrew** or **APT**.
75+
🪨 Prefer to self-host? [Download and deploy](https://www.meilisearch.com/docs/learn/self_hosted/getting_started_with_self_hosted_meilisearch?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-rust) our fast, open-source search engine on your own infrastructure.
9376

9477
## 🚀 Getting started
9578

README.tpl

Lines changed: 1 addition & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -74,164 +74,7 @@ Using this crate is possible without [serde](https://crates.io/crates/serde), bu
7474

7575
🪨 Prefer to self-host? [Download and deploy](https://www.meilisearch.com/docs/learn/self_hosted/getting_started_with_self_hosted_meilisearch?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-rust) our fast, open-source search engine on your own infrastructure.
7676

77-
## 🚀 Getting started
78-
79-
#### Add Documents <!-- omit in TOC -->
80-
81-
```rust
82-
use meilisearch_sdk::client::*;
83-
use serde::{Serialize, Deserialize};
84-
use futures::executor::block_on;
85-
86-
#[derive(Serialize, Deserialize, Debug)]
87-
struct Movie {
88-
id: usize,
89-
title: String,
90-
genres: Vec<String>,
91-
}
92-
93-
94-
#[tokio::main(flavor = "current_thread")]
95-
async fn main() {
96-
// Create a client (without sending any request so that can't fail)
97-
let client = Client::new(MEILISEARCH_URL, Some(MEILISEARCH_API_KEY)).unwrap();
98-
99-
// An index is where the documents are stored.
100-
let movies = client.index("movies");
101-
102-
// Add some movies in the index. If the index 'movies' does not exist, Meilisearch creates it when you first add the documents.
103-
movies.add_documents(&[
104-
Movie { id: 1, title: String::from("Carol"), genres: vec!["Romance".to_string(), "Drama".to_string()] },
105-
Movie { id: 2, title: String::from("Wonder Woman"), genres: vec!["Action".to_string(), "Adventure".to_string()] },
106-
Movie { id: 3, title: String::from("Life of Pi"), genres: vec!["Adventure".to_string(), "Drama".to_string()] },
107-
Movie { id: 4, title: String::from("Mad Max"), genres: vec!["Adventure".to_string(), "Science Fiction".to_string()] },
108-
Movie { id: 5, title: String::from("Moana"), genres: vec!["Fantasy".to_string(), "Action".to_string()] },
109-
Movie { id: 6, title: String::from("Philadelphia"), genres: vec!["Drama".to_string()] },
110-
], Some("id")).await.unwrap();
111-
}
112-
```
113-
114-
With the `uid`, you can check the status (`enqueued`, `canceled`, `processing`, `succeeded` or `failed`) of your documents addition using the [task](https://www.meilisearch.com/docs/reference/api/tasks#get-task).
115-
116-
#### Basic Search <!-- omit in TOC -->
117-
118-
```rust
119-
// Meilisearch is typo-tolerant:
120-
println!("{:?}", client.index("movies_2").search().with_query("caorl").execute::<Movie>().await.unwrap().hits);
121-
```
122-
123-
Output:
124-
```
125-
[Movie { id: 1, title: String::from("Carol"), genres: vec!["Romance", "Drama"] }]
126-
```
127-
128-
Json output:
129-
```json
130-
{
131-
"hits": [{
132-
"id": 1,
133-
"title": "Carol",
134-
"genres": ["Romance", "Drama"]
135-
}],
136-
"offset": 0,
137-
"limit": 10,
138-
"processingTimeMs": 1,
139-
"query": "caorl"
140-
}
141-
```
142-
143-
#### Custom Search <!-- omit in toc -->
144-
145-
```rust
146-
let search_result = client.index("movies_3")
147-
.search()
148-
.with_query("phil")
149-
.with_attributes_to_highlight(Selectors::Some(&["*"]))
150-
.execute::<Movie>()
151-
.await
152-
.unwrap();
153-
println!("{:?}", search_result.hits);
154-
```
155-
156-
Json output:
157-
```json
158-
{
159-
"hits": [
160-
{
161-
"id": 6,
162-
"title": "Philadelphia",
163-
"_formatted": {
164-
"id": 6,
165-
"title": "<em>Phil</em>adelphia",
166-
"genre": ["Drama"]
167-
}
168-
}
169-
],
170-
"offset": 0,
171-
"limit": 20,
172-
"processingTimeMs": 0,
173-
"query": "phil"
174-
}
175-
```
176-
177-
#### Custom Search With Filters <!-- omit in TOC -->
178-
179-
If you want to enable filtering, you must add your attributes to the `filterableAttributes`
180-
index setting.
181-
182-
```rust
183-
let filterable_attributes = [
184-
"id",
185-
"genres",
186-
];
187-
client.index("movies_4").set_filterable_attributes(&filterable_attributes).await.unwrap();
188-
```
189-
190-
You only need to perform this operation once.
191-
192-
Note that Meilisearch will rebuild your index whenever you update `filterableAttributes`. Depending on the size of your dataset, this might take time. You can track the process using the [tasks](https://www.meilisearch.com/docs/reference/api/tasks#get-task).
193-
194-
Then, you can perform the search:
195-
196-
```rust
197-
let search_result = client.index("movies_5")
198-
.search()
199-
.with_query("wonder")
200-
.with_filter("id > 1 AND genres = Action")
201-
.execute::<Movie>()
202-
.await
203-
.unwrap();
204-
println!("{:?}", search_result.hits);
205-
```
206-
207-
Json output:
208-
```json
209-
{
210-
"hits": [
211-
{
212-
"id": 2,
213-
"title": "Wonder Woman",
214-
"genres": ["Action", "Adventure"]
215-
}
216-
],
217-
"offset": 0,
218-
"limit": 20,
219-
"estimatedTotalHits": 1,
220-
"processingTimeMs": 0,
221-
"query": "wonder"
222-
}
223-
```
224-
225-
#### Customize the `HttpClient` <!-- omit in TOC -->
226-
227-
By default, the SDK uses [`reqwest`](https://docs.rs/reqwest/latest/reqwest/) to make http calls.
228-
The SDK lets you customize the http client by implementing the `HttpClient` trait yourself and
229-
initializing the `Client` with the `new_with_client` method.
230-
You may be interested by the `futures-unsend` feature which lets you specify a non-Send http client.
231-
232-
#### Wasm support <!-- omit in TOC -->
233-
234-
The SDK supports wasm through reqwest. You'll need to enable the `futures-unsend` feature while importing it, though.
77+
{{readme}}
23578

23679
## 🌐 Running in the Browser with WASM <!-- omit in TOC -->
23780

0 commit comments

Comments
 (0)