Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 38 additions & 57 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,15 @@ update_settings_1: |-
])
.with_distinct_attribute("movie_id".to_string())
.with_searchable_attributes(vec![
"uid".to_string(),
"movie_id".to_string(),
"title".to_string(),
"description".to_string(),
"poster".to_string(),
"release_date".to_string(),
"rank".to_string()
"genre".to_string()
])
.with_displayed_attributes(vec![
"title".to_string(),
"description".to_string(),
"poster".to_string(),
"release_date".to_string(),
"rank".to_string()
"genre".to_string(),
"release_date".to_string()
])
.with_stop_words(vec![
"the".to_string(),
Expand Down Expand Up @@ -157,7 +152,7 @@ update_searchable_attributes_1: |-
let searchable_attributes = &[
"title",
"description",
"uid"
"genre"
];

let progress: Progress = movies.set_searchable_attributes(searchable_attributes).await.unwrap();
Expand All @@ -180,9 +175,8 @@ update_displayed_attributes_1: |-
let displayed_attributes = &[
"title",
"description",
"release_date",
"rank",
"poster"
"genre",
"release_date"
];

let progress: Progress = movies.set_displayed_attributes(displayed_attributes).await.unwrap();
Expand All @@ -202,23 +196,18 @@ distinct_attribute_guide_1: |-
let progress: Progress = jackets.set_distinct_attribute("product_id").await.unwrap();
field_properties_guide_searchable_1: |-
let searchable_attributes = &[
"uid",
"movie_id",
"title",
"description",
"poster",
"release_date",
"rank"
"genre"
];

let progress: Progress = movies.set_searchable_attributes(searchable_attributes).await.unwrap();
field_properties_guide_displayed_1: |-
let displayed_attributes = &[
"title",
"description",
"poster",
"release_date",
"rank"
"genre",
"release_date"
];

let progress: Progress = movies.set_displayed_attributes(displayed_attributes).await.unwrap();
Expand Down Expand Up @@ -353,23 +342,18 @@ settings_guide_distinct_1: |-
let progress: Progress = jackets.set_distinct_attribute("product_id").await.unwrap();
settings_guide_searchable_1: |-
let searchable_attributes = &[
"uid",
"movie_id",
"title",
"description",
"poster",
"release_date",
"rank"
"genre"
];

let progress: Progress = movies.set_searchable_attributes(searchable_attributes).await.unwrap();
settings_guide_displayed_1: |-
let displayed_attributes = &[
"title",
"description",
"poster",
"release_date",
"rank"
"genre",
"release_date"
];

let progress: Progress = movies.set_displayed_attributes(displayed_attributes).await.unwrap();
Expand Down Expand Up @@ -407,31 +391,15 @@ search_guide_2: |-
.execute()
.await
.unwrap();
getting_started_create_index_md: |-
getting_started_add_documents_md: |-
```toml
[dependencies]
meilisearch-sdk = "0.4"
tokio = { version = "0.2", features = ["macros"] } # required if you are not targeting wasm
serde = { version="1.0", features = ["derive"] } # required if you are going to use documents
serde_json = "1.0" # required in some parts of this guide
```

```rust
use meilisearch_sdk::{indexes::*, document::*, client::*, search::*, progress::*, settings::*};
use serde::{Serialize, Deserialize};

#[tokio::main]
async fn main() {
let client = Client::new("http://localhost:7700", "masterKey");
// create an index if the index does not exist
let movies = client.get_or_create("movies").await.unwrap();

// some code
}
[dependencies]
meilisearch-sdk = "0.4"
tokio = { version = "0.2", features = ["macros"] } # required if you are not targeting wasm
serde = { version="1.0", features = ["derive"] } # required if you are going to use documents
serde_json = "1.0" # required in some parts of this guide
```

[About this crate](https://github.com/meilisearch/meilisearch-rust)
getting_started_add_documents_md: |-
Documents in the Rust library are strongly typed.
You have to implement the `Document` trait on a struct to be able to use it with Meilisearch.

Expand Down Expand Up @@ -471,16 +439,27 @@ getting_started_add_documents_md: |-
Then, add documents into the index:

```rust
// reading and parsing the file
use meilisearch_sdk::{indexes::*, document::*, client::*, search::*, progress::*, settings::*};
use serde::{Serialize, Deserialize};
use std::{io::prelude::*, fs::File};
let mut file = File::open("movies.json").unwrap();
let mut content = String::new();
file.read_to_string(&mut content).unwrap();
let movies_docs: Vec<Movie> = serde_json::from_str(&content).unwrap();

// adding documents
movies.add_documents(&movies_docs, None).await.unwrap();
#[tokio::main]
async fn main() {
let client = Client::new("http://localhost:7700", "masterKey");

// reading and parsing the file
let mut file = File::open("movies.json").unwrap();
let mut content = String::new();
file.read_to_string(&mut content).unwrap();
let movies_docs: Vec<Movie> = serde_json::from_str(&content).unwrap();

// adding documents
let movies = client.get_or_create_index("movies").await.unwrap();
movies.add_documents(&movies_docs, None).await.unwrap();
}
```

[About this package](https://github.com/meilisearch/meilisearch-rust/)
getting_started_search_md: |-
You can build a Query and execute it later:
```rust
Expand Down Expand Up @@ -508,6 +487,8 @@ getting_started_search_md: |-
.await
.unwrap();
```

[About this package](https://github.com/meilisearch/meilisearch-rust/)
faceted_search_update_settings_1: |-
let progress: Progress = movies.set_attributes_for_faceting(&["director", "genres"]).await.unwrap();
faceted_search_facet_filters_1: |-
Expand Down