@@ -8,9 +8,9 @@ get_one_index_1: |-
88list_all_indexes_1 : |-
99 let indexes: Vec<Index> = client.list_all_indexes().await.unwrap();
1010create_an_index_1 : |-
11- let movies: Index = client.create_index("movies", Some("movie_id ")).await.unwrap();
11+ client.create_index("movies", Some("id ")).await.unwrap();
1212update_an_index_1 : |-
13- client.index("movies").update("movie_review_id").await.unwrap();
13+ client.index("movies").update("movie_review_id", Some("id") ).await.unwrap();
1414delete_an_index_1 : |-
1515 client.index("movies").delete().await.unwrap();
1616get_one_document_1 : |-
@@ -87,13 +87,13 @@ update_settings_1: |-
8787 .with_distinct_attribute("movie_id")
8888 .with_searchable_attributes([
8989 "title",
90- "description ",
91- "genre "
90+ "overview ",
91+ "genres "
9292 ])
9393 .with_displayed_attributes([
9494 "title",
95- "description ",
96- "genre ",
95+ "overview ",
96+ "genres ",
9797 "release_date"
9898 ])
9999 .with_stop_words([
@@ -156,8 +156,8 @@ get_searchable_attributes_1: |-
156156update_searchable_attributes_1 : |-
157157 let searchable_attributes = [
158158 "title",
159- "description ",
160- "genre "
159+ "overview ",
160+ "genres "
161161 ];
162162
163163 let task: Task = client.index("movies").set_searchable_attributes(&searchable_attributes).await.unwrap();
@@ -179,8 +179,8 @@ get_displayed_attributes_1: |-
179179update_displayed_attributes_1 : |-
180180 let displayed_attributes = [
181181 "title",
182- "description ",
183- "genre ",
182+ "overview ",
183+ "genres ",
184184 "release_date"
185185 ];
186186
@@ -201,16 +201,16 @@ distinct_attribute_guide_1: |-
201201field_properties_guide_searchable_1 : |-
202202 let searchable_attributes = [
203203 "title",
204- "description ",
205- "genre "
204+ "overvieww ",
205+ "genres "
206206 ];
207207
208208 let task: Task = client.index("movies").set_searchable_attributes(&searchable_attributes).await.unwrap();
209209field_properties_guide_displayed_1 : |-
210210 let displayed_attributes = [
211211 "title",
212- "description ",
213- "genre ",
212+ "overvieww ",
213+ "genres ",
214214 "release_date"
215215 ];
216216
@@ -230,13 +230,6 @@ filtering_guide_2: |-
230230 .await
231231 .unwrap();
232232filtering_guide_3 : |-
233- let results: SearchResults<Movie> = client.index("movies").search()
234- .with_query("horror")
235- .with_filter(r#"director = "Jordan Peele""#)
236- .execute()
237- .await
238- .unwrap();
239- filtering_guide_4 : |-
240233 let results: SearchResults<Movie> = client.index("movies").search()
241234 .with_query("Planet of the Apes")
242235 .with_filter(r#"rating >= 3 AND (NOT director = "Tim Burton")"#)
@@ -291,20 +284,6 @@ search_parameter_guide_highlight_1: |-
291284
292285 // Get the formatted results
293286 let formatted_results: Vec<&Movie> = results.hits.iter().map(|r| r.formatted_result.as_ref().unwrap()).collect();
294- search_parameter_guide_filter_1 : |-
295- let results: SearchResults<Movie> = client.index("movies").search()
296- .with_query("n")
297- .with_filter("title = Nightshift")
298- .execute()
299- .await
300- .unwrap();
301- search_parameter_guide_filter_2 : |-
302- let results: SearchResults<Movie> = client.index("movies").search()
303- .with_query("shifu")
304- .with_filter(r#"title = "Kung Fu Panda""#)
305- .execute()
306- .await
307- .unwrap();
308287search_parameter_guide_matches_1 : |-
309288 let results: SearchResults<Movie> = client.index("movies").search()
310289 .with_query("winter feast")
@@ -364,17 +343,17 @@ settings_guide_searchable_1: |-
364343 let settings = Settings::new()
365344 .with_searchable_attributes([
366345 "title",
367- "description ",
368- "genre "
346+ "overview ",
347+ "genres "
369348 ]);
370349
371350 let task: Task = client.index("movies").set_settings(&settings).await.unwrap();
372351settings_guide_displayed_1 : |-
373352 let settings = Settings::new()
374353 .with_displayed_attributes([
375354 "title",
376- "description ",
377- "genre ",
355+ "overview ",
356+ "genres ",
378357 "release_date"
379358 ]);
380359
@@ -430,21 +409,31 @@ documents_guide_add_movie_1: |-
430409 title: "Amélie Poulain".to_string(),
431410 }
432411 ], None).await.unwrap();
433- search_guide_1 : |-
434- let results: SearchResults<Movie> = client.index("movies").search()
435- .with_query("shifu")
436- .with_limit(5)
437- .with_offset(10)
438- .execute()
439- .await
440- .unwrap();
441- search_guide_2 : |-
442- let results: SearchResults<Movie> = client.index("movies").search()
443- .with_query("Avengers")
444- .with_filter("release_date > 795484800")
445- .execute()
446- .await
447- .unwrap();
412+ document_guide_create_index_primary_key : |-
413+ client.create_index("movies", Some("reference_number")).await.unwrap();
414+ document_guide_add_document_primary_key : |-
415+ #[derive(Serialize, Deserialize, Debug)]
416+ struct Movie {
417+ id: String,
418+ title: String,
419+ poster: String,
420+ overview: String,
421+ release_date: String
422+ }
423+ impl Document for Movie {
424+ type UIDType = String;
425+ fn get_uid(&self) -> &Self::UIDType { &self.id }
426+ }
427+
428+ let task: Task = client.index("movies").add_documents(&[
429+ Movie {
430+ "reference_number": "287947".to_string(),
431+ "title": "Shazam".to_string(),
432+ "poster": "https://image.tmdb.org/t/p/w1280/xnopI5Xtky18MPhK40cZAGAOVeV.jpg".to_string(),
433+ "overview": "A boy is given the ability to become an adult superhero in times of need with a single magic word.".to_string(),
434+ "release_date": "2019-03-23".to_string()
435+ }
436+ ], Some("reference_number")).await.unwrap();
448437getting_started_add_documents_md : |-
449438 ```toml
450439 [dependencies]
@@ -551,6 +540,112 @@ getting_started_search_md: |-
551540 ```
552541
553542 [About this SDK](https://github.com/meilisearch/meilisearch-rust/)
543+ getting_started_update_rankingRules : |-
544+ let ranking_rules = [
545+ "exactness",
546+ "words",
547+ "typo",
548+ "proximity",
549+ "attribute",
550+ "sort",
551+ "release_date:asc",
552+ "rank:desc"
553+ ];
554+
555+ client.index("movies").set_ranking_rules(&ranking_rules).await.unwrap();
556+ getting_started_update_searchableAttributes : |-
557+ let searchable_attributes = [
558+ "title"
559+ ];
560+
561+ client.index("movies").set_searchable_attributes(&searchable_attributes).await.unwrap();
562+ getting_started_update_stop_words : |-
563+ let stop_words = ["the"];
564+ client.index("movies").set_stop_words(&stop_words).await.unwrap();
565+ getting_started_check_task_status : |-
566+ client.index("movies").get_task(0).await.unwrap();
567+ getting_started_synonyms : |-
568+ let mut synonyms = std::collections::HashMap::new();
569+ synonyms.insert(String::from("winnie"), vec![String::from("piglet")]);
570+ synonyms.insert(String::from("piglet"), vec![String::from("winnie")]);
571+
572+ client.index("movies").set_synonyms(&synonyms).await.unwrap();
573+ getting_started_update_displayedAttributes : |-
574+ let displayed_attributes = [
575+ "title",
576+ "overview",
577+ "poster",
578+ ];
579+
580+ client.index("movies").set_displayed_attributes(&displayed_attributes).await.unwrap();
581+ getting_started_communicating_with_a_protected_instance : |-
582+ let client = Client::new("http://localhost:7700", "apiKey");
583+ client.index("movies").search()
584+ getting_started_add_meteorites : |-
585+ use serde::Deserialize;
586+ use std::fs::File;
587+
588+ #[derive(Serialize, Deserialize, Debug)]
589+ struct Geo {
590+ lat: f64,
591+ lon: f64
592+ }
593+
594+ struct Meteorite {
595+ name: String,
596+ id: String,
597+ nametype: String,
598+ recclass: String,
599+ mass: i64,
600+ fall: String,
601+ _geo: Geo
602+ }
603+
604+ impl Document for Meteorite {
605+ type UIDType = String;
606+ fn get_uid(&self) -> &Self::UIDType { &self.id }
607+ }
608+
609+ let mut file = File::open("meteorites.json")?;
610+ let meteorites: Vec<Meteorite> = serde_json::from_reader(file)?;
611+
612+ client.index("meteorites").add_documents(&meteorites, None).await?;
613+ getting_started_configure_settings : |-
614+ let settings = Settings::new()
615+ .with_filterable_attributes([
616+ "mass",
617+ "geo"
618+ ])
619+ .with_sortable_attributes([
620+ "mass",
621+ "geo"
622+ ])
623+ let task: Task = client.index("meteorites").set_settings(&settings).await.unwrap();
624+ getting_started_geoRadius : |-
625+ let results: SearchResults<Meteorite> = client.index("meteorites").search()
626+ .with_filter("_geoRadius(46.9480, 7.4474, 210000)")
627+ .execute()
628+ .await
629+ .unwrap();
630+ getting_started_geoPoint : |-
631+ let results: SearchResults<Meteorite> = client.index("meteorites").search()
632+ .with_sort(&["_geoPoint(48.8583701, 2.2922926):asc"])
633+ .execute()
634+ .await
635+ .unwrap();
636+ getting_started_sorting : |-
637+ let results: SearchResults<Meteorite> = client.index("meteorites").search()
638+ .with_filter("mass < 200")
639+ .with_sort(&["mass:asc"])
640+ .execute()
641+ .await
642+ .unwrap();
643+ getting_started_filtering : |-
644+ let results: SearchResults<Meteorite> = client.index("meteorites").search()
645+ .with_filter("mass < 200")
646+ .execute()
647+ .await
648+ .unwrap();
554649faceted_search_update_settings_1 : |-
555650 let task: Task = client.index("movies").set_filterable_attributes(["director", "genres"]).await.unwrap();
556651faceted_search_filter_1 : |-
@@ -568,30 +663,13 @@ faceted_search_facets_distribution_1: |-
568663 .await
569664 .unwrap();
570665 let genres: &HashMap<String, usize> = results.facets_distribution.unwrap().get("genres").unwrap();
571- faceted_search_walkthrough_filterable_attributes_1 : |-
572- let filterable_attributes = [
573- "director",
574- "producer",
575- "genres",
576- "production_companies"
577- ];
578-
579- let task: Task = client.index("movies").set_filterable_attributes(&filterable_attributes).await.unwrap();
580666faceted_search_walkthrough_filter_1 : |-
581667 let results: SearchResults<Movie> = client.index("movies").search()
582668 .with_query("thriller")
583669 .with_filter("(genres = Horror AND genres = Mystery) OR director = \"Jordan Peele\"")
584670 .execute()
585671 .await
586672 .unwrap();
587- faceted_search_walkthrough_facets_distribution_1 : |-
588- let results: SearchResults<Movie> = client.index("movies").search()
589- .with_query("Batman")
590- .with_facets_distribution(Selectors::Some(&["genres"]))
591- .execute()
592- .await
593- .unwrap();
594- let genres: &HashMap<String, usize> = results.facets_distribution.unwrap().get("genres").unwrap();
595673post_dump_1 : |-
596674 client.create_dump().await.unwrap();
597675get_dump_status_1 : |-
@@ -657,27 +735,27 @@ geosearch_guide_filter_settings_1: |-
657735 let task: Task = client.index("restaurants").set_filterable_attributes(&["_geo"]).await.unwrap();
658736geosearch_guide_filter_usage_1 : |-
659737 let results: SearchResults<Restaurant> = client.index("restaurants").search()
660- .with_filter("_geoRadius(45.4628328 , 9.1076931 , 2000)")
738+ .with_filter("_geoRadius(45.472735 , 9.184019 , 2000)")
661739 .execute()
662740 .await
663741 .unwrap();
664742geosearch_guide_filter_usage_2 : |-
665743 let results: SearchResults<Restaurant> = client.index("restaurants").search()
666- .with_filter("_geoRadius(45.4628328 , 9.1076931 , 2000) AND type = pizza")
744+ .with_filter("_geoRadius(45.472735 , 9.184019 , 2000) AND type = pizza")
667745 .execute()
668746 .await
669747 .unwrap();
670748geosearch_guide_sort_settings_1 : |-
671749 let task: Task = client.index("restaurants").set_sortable_attributes(&["_geo"]).await.unwrap();
672750geosearch_guide_sort_usage_1 : |-
673751 let results: SearchResults<Restaurant> = client.index("restaurants").search()
674- .with_sort(&["_geoPoint(48.8583701,2.2922926 ):asc"])
752+ .with_sort(&["_geoPoint(48.8561446, 2.2978204 ):asc"])
675753 .execute()
676754 .await
677755 .unwrap();
678756geosearch_guide_sort_usage_2 : |-
679757 let results: SearchResults<Restaurant> = client.index("restaurants").search()
680- .with_sort(&["_geoPoint(48.8583701,2.2922926 ):asc", "rating:desc"])
758+ .with_sort(&["_geoPoint(48.8561446, 2.2978204 ):asc", "rating:desc"])
681759 .execute()
682760 .await
683761 .unwrap();
@@ -726,3 +804,24 @@ security_guide_delete_key_1: |-
726804 let client = Client::new("http://localhost:7700", "masterKey");
727805 let key = client.get_key("d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4").await.unwrap();
728806 client.delete_key(&key);
807+ landing_getting_started_1 : |-
808+ let client = Client::new("http://localhost:7700", "masterKey");
809+
810+ #[derive(Serialize, Deserialize, Debug)]
811+ struct Movie {
812+ id: String,
813+ title: String
814+ }
815+ impl Document for Movie {
816+ type UIDType = String;
817+ fn get_uid(&self) -> &Self::UIDType { &self.id }
818+ }
819+
820+ client.index("movies").add_documents(&[
821+ Movie { "id": "1".to_string(), "title": "Carol".to_string() },
822+ Movie { "id": "2".to_string(), "title": "Wonder Woman".to_string() },
823+ Movie { "id": "3".to_string(), "title": "Life of Pi".to_string() },
824+ Movie { "id": "4".to_string(), "title": "Mad Max: Fury Road".to_string() },
825+ Movie { "id": "5".to_string(), "title": "Moana".to_string() },
826+ Movie { "id": "6".to_string(), "title": "Philadelphia".to_string() }
827+ ], Some("reference_number")).await.unwrap();
0 commit comments