@@ -102,24 +102,24 @@ impl Document for Movie {
102102}
103103
104104fn main () { block_on (async move {
105+ // Create a client (without sending any request so that can't fail)
105106 let client = Client :: new (" http://localhost:7700" , " masterKey" );
106107
107- // An index is where the documents are stored.
108+ // Get the index called "movies"
108109 let movies = client . get_or_create (" movies" ). await . unwrap ();
109110
110111 // Add some movies in the index
111112 movies . add_documents (& [
112- Movie {id : 1 , title : String :: from (" Carol" ), genres : vec! [" Romance" , " Drama" ]},
113- Movie {id : 2 , title : String :: from (" Wonder Woman" ), genres : vec! [" Action" , " Adventure" ]},
114- Movie {id : 3 , title : String :: from (" Life of Pi" ), genres : vec! [" Adventure" , " Drama" ]},
115- Movie {id : 4 , title : String :: from (" Mad Max" ), genres : vec! [" Adventure" , " Science Fiction" ]},
116- Movie {id : 5 , title : String :: from (" Moana" ), genres : vec! [" Fantasy" , " Action" ]},
117- Movie {id : 6 , title : String :: from (" Philadelphia" ), genres : vec! [" Drama" ]},
113+ Movie {id : 1 , title : String :: from (" Carol" ), genres : vec! [" Romance" . to_string () , " Drama" . to_string () ]},
114+ Movie {id : 2 , title : String :: from (" Wonder Woman" ), genres : vec! [" Action" . to_string () , " Adventure" . to_string () ]},
115+ Movie {id : 3 , title : String :: from (" Life of Pi" ), genres : vec! [" Adventure" . to_string () , " Drama" . to_string () ]},
116+ Movie {id : 4 , title : String :: from (" Mad Max" ), genres : vec! [" Adventure" . to_string () , " Science Fiction" . to_string () ]},
117+ Movie {id : 5 , title : String :: from (" Moana" ), genres : vec! [" Fantasy" . to_string () , " Action" . to_string () ]},
118+ Movie {id : 6 , title : String :: from (" Philadelphia" ), genres : vec! [" Drama" . to_string () ]},
118119 ], Some (" id" )). await . unwrap ();
119120
120- // Search in "movies"
121- // MeiliSearch is typo-tolerant:
122- println! (" {:?}" , movies . search (). with_query (" carlo" ). execute :: <Movie >(). await . unwrap (). hits);
121+ // Query movies (note that there is a typo)
122+ println! (" {:?}" , movies . search (). with_query (" carol" ). execute :: <Movie >(). await . unwrap (). hits);
123123})}
124124```
125125
0 commit comments