@@ -117,26 +117,27 @@ fn main() { block_on(async move {
117117
118118    //  Add some movies in the index. If the index 'movies' does not exist, Meilisearch creates it when you first add the documents.
119119    movies . add_documents (& [
120-         Movie { id :  1 , title :  String :: from (" Carol" genres :  vec! [" Romance" . to_string (), " Drama" . to_string ()]},
121-         Movie { id :  2 , title :  String :: from (" Wonder Woman" genres :  vec! [" Action" . to_string (), " Adventure" . to_string ()]},
122-         Movie { id :  3 , title :  String :: from (" Life of Pi" genres :  vec! [" Adventure" . to_string (), " Drama" . to_string ()]},
123-         Movie { id :  4 , title :  String :: from (" Mad Max" genres :  vec! [" Adventure" . to_string (), " Science Fiction" . to_string ()]},
124-         Movie { id :  5 , title :  String :: from (" Moana" genres :  vec! [" Fantasy" . to_string (), " Action" . to_string ()]},
125-         Movie { id :  6 , title :  String :: from (" Philadelphia" genres :  vec! [" Drama" . to_string ()]},
120+         Movie  {  id :  1 , title :  String :: from (" Carol" genres :  vec! [" Romance" . to_string (), " Drama" . to_string ()]  },
121+         Movie  {  id :  2 , title :  String :: from (" Wonder Woman" genres :  vec! [" Action" . to_string (), " Adventure" . to_string ()]  },
122+         Movie  {  id :  3 , title :  String :: from (" Life of Pi" genres :  vec! [" Adventure" . to_string (), " Drama" . to_string ()]  },
123+         Movie  {  id :  4 , title :  String :: from (" Mad Max" genres :  vec! [" Adventure" . to_string (), " Science Fiction" . to_string ()]  },
124+         Movie  {  id :  5 , title :  String :: from (" Moana" genres :  vec! [" Fantasy" . to_string (), " Action" . to_string ()]  },
125+         Movie  {  id :  6 , title :  String :: from (" Philadelphia" genres :  vec! [" Drama" . to_string ()]  },
126126    ], Some (" id" . await . unwrap ();
127127})}
128128``` 
129129
130130#### Basic Search <!--  omit in TOC -->   
131131
132132``` rust 
133+ #
133134//  Meilisearch is typo-tolerant:
134- println! (" {:?}" client . index ( " movies" ) . search (). with_query (" caorl" . execute :: <Movie >(). await . unwrap (). hits);
135+ println! (" {:?}" movies . search (). with_query (" caorl" . execute :: <Movie >(). await . unwrap (). hits);
135136``` 
136137
137138Output:
138139``` 
139- [Movie{ id: 1, title: String::from("Carol"), genres: vec!["Romance", "Drama"]}] 
140+ [Movie {  id: 1, title: String::from("Carol"), genres: vec!["Romance", "Drama"]  }] 
140141``` 
141142
142143Json output:
@@ -157,7 +158,15 @@ Json output:
157158#### Custom Search <!--  omit in toc -->   
158159
159160``` rust 
160- println! (" {:?}" client . index (" movies" . search (). with_query (" phil" . with_attributes_to_highlight (Selectors :: Some (& [" *" . execute :: <Movie >(). await . unwrap (). hits);
161+ #
162+ let  search_result  =  movies 
163+   . search ()
164+   . with_query (" phil" 
165+   . with_attributes_to_highlight (Selectors :: Some (& [" *" 
166+   . execute :: <Movie >()
167+   . await 
168+   . unwrap ();
169+ println! (" {:?}" search_result . hits);
161170``` 
162171
163172Json output:
@@ -189,9 +198,9 @@ index setting.
189198``` rust 
190199let  filterable_attributes  =  [
191200    " id" 
192-     " genres" 
201+     " genres" , 
193202];
194- client . index ( " movies" ) . set_filterable_attributes (& filterable_attributes ). await . unwrap ();
203+ movies . set_filterable_attributes (& filterable_attributes ). await . unwrap ();
195204``` 
196205
197206You only need to perform this operation once.
@@ -204,8 +213,15 @@ status](https://docs.meilisearch.com/reference/api/updates.html#get-an-update-st
204213Then, you can perform the search:
205214
206215``` rust 
207- println! (" {:?}" client . index (" movies" . search (). with_query (" wonder" . with_filter (" id > 1 AND genres = Action" 
208- . execute :: <Movie >(). await . unwrap (). hits);
216+ #
217+ let  search_result  =  movies 
218+   . search ()
219+   . with_query (" wonder" 
220+   . with_filter (" id > 1 AND genres = Action" 
221+   . execute :: <Movie >()
222+   . await 
223+   . unwrap ();
224+ println! (" {:?}" search_result . hits);
209225``` 
210226
211227Json output:
0 commit comments