Skip to content

Commit 25cd089

Browse files
bors[bot]curquiza
andauthored
Merge #228
228: Update docs according to v0.25.0 r=curquiza a=curquiza - Remove `update` mention from the README - rename `update_type` to `task_type` - Add code samples for v0.25.0 according to https://github.com/meilisearch/documentation/pull/1288/files Co-authored-by: Clémentine Urquizar <[email protected]>
2 parents 6685d0c + 7382c19 commit 25cd089

File tree

4 files changed

+66
-25
lines changed

4 files changed

+66
-25
lines changed

.code-samples.meilisearch.yaml

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,14 @@ search_post_1: |-
5858
.execute()
5959
.await
6060
.unwrap();
61-
get_update_1: |-
62-
// You can get the status of a `Progress` object:
63-
let status: Status = progress.get_status().await.unwrap();
64-
65-
// Or you can use index to get an update status using its `update_id`:
66-
let status: Status = client.index("movies").get_update(1).await.unwrap();
67-
get_all_updates_1: |-
68-
let status: Vec<ProgressStatus> = client.index("movies").get_all_updates().await.unwrap();
69-
get_keys_1: |-
70-
let keys: Keys = client.get_keys().await.unwrap();
61+
get_task_by_index_1: |-
62+
let task: Task = client.index("movies").get_task(1).await.unwrap();
63+
get_all_tasks_by_index_1: |-
64+
let tasks: Vec<Task> = client.index("movies").get_tasks().await.unwrap();
65+
get_all_tasks_1: |-
66+
let tasks: Vec<Task> = client.get_tasks().await.unwrap();
67+
get_task_1: |-
68+
let task: Task = client.get_task(1).await.unwrap();
7169
get_settings_1: |-
7270
let settings: Settings = client.index("movies").get_settings().await.unwrap();
7371
update_settings_1: |-
@@ -685,3 +683,48 @@ geosearch_guide_sort_usage_2: |-
685683
.execute()
686684
.await
687685
.unwrap();
686+
get_one_key_1: |-
687+
let key = client.get_key("d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4").await.unwrap();
688+
get_all_keys_1: |-
689+
let keys = client.get_keys().await.unwrap();
690+
create_a_key_1: |-
691+
let mut key_options = KeyBuilder::new("Add documents: Products API key");
692+
key_options.with_action(Action::DocumentsAdd)
693+
.with_expires_at("2042-04-02T00:42:42Z")
694+
.with_index("products");
695+
let new_key = client.create_key(key_options).await.unwrap();
696+
update_a_key_1: |-
697+
let key = client.get_key("d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4").await.unwrap();
698+
key.description = "Manage documents: Products/Reviews API key".to_string();
699+
key.actions = vec![Action::DocumentsAdd, Action::DocumentsDelete];
700+
key.indexes = vec!["products".to_string(), "reviews".to_string()];
701+
key.expires_at = Some("2042-04-02T00:42:42Z".to_string());
702+
let updated_key = client.update_key(&key);
703+
delete_a_key_1: |-
704+
let key = client.get_key("d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4").await.unwrap();
705+
client.delete_key(&key);
706+
authorization_header_1:
707+
let client = Client::new("http://localhost:7700", "masterKey");
708+
let keys = client.get_keys().await.unwrap();
709+
security_guide_search_key_1: |-
710+
let client = Client::new("http://localhost:7700", "apiKey");
711+
let result = client.index("patient_medical_records").search().execute().await.unwrap();
712+
security_guide_update_key_1: |-
713+
let client = Client::new("http://localhost:7700", "masterKey");
714+
let key = client.get_key("d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4").await.unwrap();
715+
key.indexes = vec!["doctors".to_string()];
716+
let updated_key = client.update_key(&key);
717+
security_guide_create_key_1: |-
718+
let client = Client::new("http://localhost:7700", "masterKey");
719+
let mut key_options = KeyBuilder::new("Search patient records key");
720+
key_options.with_action(Action::Search)
721+
.with_expires_at("2023-01-01T00:00:00Z")
722+
.with_index("patient_medical_records");
723+
let new_key = client.create_key(key_options).await.unwrap();
724+
security_guide_list_keys_1: |-
725+
let client = Client::new("http://localhost:7700", "masterKey");
726+
let keys = client.get_keys().await.unwrap();
727+
security_guide_delete_key_1: |-
728+
let client = Client::new("http://localhost:7700", "masterKey");
729+
let key = client.get_key("d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4").await.unwrap();
730+
client.delete_key(&key);

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ fn main() { block_on(async move {
127127
})}
128128
```
129129

130+
With the `uid`, you can check the status (`enqueued`, `processing`, `succeeded` or `failed`) of your documents addition using the [task](https://docs.meilisearch.com/reference/api/tasks.html#get-task).
131+
130132
#### Basic Search <!-- omit in TOC -->
131133

132134
```rust
@@ -203,10 +205,7 @@ client.index("movies_4").set_filterable_attributes(&filterable_attributes).await
203205

204206
You only need to perform this operation once.
205207

206-
Note that Meilisearch will rebuild your index whenever you update `filterableAttributes`.
207-
Depending on the size of your dataset, this might take time. You can track the whole process
208-
using the [update
209-
status](https://docs.meilisearch.com/reference/api/updates.html#get-an-update-status).
208+
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://docs.meilisearch.com/reference/api/tasks.html#get-task)).
210209

211210
Then, you can perform the search:
212211

meilisearch-test-macro/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ The macro aims to ease the writing of tests by:
1212
Before explaining its usage, we're going to see a simple test *before* this macro:
1313
```rust
1414
#[async_test]
15-
async fn test_get_all_tasks() -> Result<(), Error> {
15+
async fn test_get_tasks() -> Result<(), Error> {
1616
let client = Client::new("http://localhost:7700", "masterKey");
1717

1818
let index = client
19-
.create_index("test_get_all_tasks", None)
19+
.create_index("test_get_tasks", None)
2020
.await?
2121
.wait_for_completion(&client, None, None)
2222
.await?
2323
.try_make_index(&client)
2424
.unwrap();
2525

26-
let tasks = index.get_all_tasks().await?;
26+
let tasks = index.get_tasks().await?;
2727
// The only task is the creation of the index
2828
assert_eq!(status.len(), 1);
29-
29+
3030
index.delete()
3131
.await?
3232
.wait_for_completion(&client, None, None)
@@ -38,7 +38,7 @@ async fn test_get_all_tasks() -> Result<(), Error> {
3838
I have multiple problems with this test:
3939
- `let client = Client::new("http://localhost:7700", "masterKey");`: This line is always the same in every test.
4040
And if you make a typo on the http addr or the master key, you'll have an error.
41-
- `let index = client.create_index("test_get_all_tasks", None)...`: Each test needs to have an unique name.
41+
- `let index = client.create_index("test_get_tasks", None)...`: Each test needs to have an unique name.
4242
This means we currently need to write the name of the test everywhere; it's not practical.
4343
- There are 11 lines dedicated to the creation and deletion of the index; this is once again something that'll never change
4444
whatever the test is. But, if you ever forget to delete the index at the end, you'll get in some trouble to re-run
@@ -49,8 +49,8 @@ I have multiple problems with this test:
4949
With this macro, all these problems are solved. See a rewrite of this test:
5050
```rust
5151
#[meilisearch_test]
52-
async fn test_get_all_tasks(index: Index, client: Client) -> Result<(), Error> {
53-
let tasks = index.get_all_tasks().await?;
52+
async fn test_get_tasks(index: Index, client: Client) -> Result<(), Error> {
53+
let tasks = index.get_tasks().await?;
5454
// The only task is the creation of the index
5555
assert_eq!(status.len(), 1);
5656
}

src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
//! })}
4545
//! ```
4646
//!
47+
//! With the `uid`, you can check the status (`enqueued`, `processing`, `succeeded` or `failed`) of your documents addition using the [task](https://docs.meilisearch.com/reference/api/tasks.html#get-task).
48+
//!
4749
//! ### Basic Search <!-- omit in TOC -->
4850
//!
4951
//! ```rust
@@ -168,10 +170,7 @@
168170
//!
169171
//! You only need to perform this operation once.
170172
//!
171-
//! Note that Meilisearch will rebuild your index whenever you update `filterableAttributes`.
172-
//! Depending on the size of your dataset, this might take time. You can track the whole process
173-
//! using the [update
174-
//! status](https://docs.meilisearch.com/reference/api/updates.html#get-an-update-status).
173+
//! 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://docs.meilisearch.com/reference/api/tasks.html#get-task)).
175174
//!
176175
//! Then, you can perform the search:
177176
//!

0 commit comments

Comments
 (0)