|
56 | 56 | //! } |
57 | 57 | //! } |
58 | 58 | //! |
59 | | -// !fn main() { block_on(async move { |
60 | | -// ! // Create a client (without sending any request so that can't fail) |
61 | | -// ! let client = Client::new("http://localhost:7700", "masterKey"); |
62 | | -// ! |
63 | | -// ! // Get the index called "movies" |
64 | | -// ! let movies = client.get_or_create("movies").await.unwrap(); |
65 | | -// ! |
66 | | -// ! // Add some movies in the index |
67 | | -// ! movies.add_documents(&[ |
68 | | -// ! Movie{id: 1, title: String::from("Carol"), genres: vec!["Romance", "Drama"]}, |
69 | | -// ! Movie{id: 2, title: String::from("Wonder Woman"), genres: vec!["Action", "Adventure"]}, |
70 | | -// ! Movie{id: 3, title: String::from("Life of Pi"), genres: vec!["Adventure", "Drama"]}, |
71 | | -// ! Movie{id: 4, title: String::from("Mad Max"), genres: vec!["Adventure", "Science Fiction"]}, |
72 | | -// ! Movie{id: 5, title: String::from("Moana"), genres: vec!["Fantasy", "Action"]}, |
73 | | -// ! Movie{id: 6, title: String::from("Philadelphia"), genres: vec!["Drama"]}, |
74 | | -// ! ], Some("id")).await.unwrap(); |
75 | | -// ! |
76 | | -// ! // Query movies (note that there is a typo) |
77 | | -// ! println!("{:?}", movies.search().with_query("Carol").execute::<Movie>().await.unwrap().hits); |
78 | | -// !})} |
79 | | -// !``` |
80 | | -// ! |
81 | | -// !Output: |
82 | | -// ! |
83 | | -// !``` |
84 | | -// ![Movie{id: 1, title: String::from("Carol"), genres: vec!["Romance", "Drama"]}] |
85 | | -// !``` |
| 59 | +//! fn main() { block_on(async move { |
| 60 | +//! // Create a client (without sending any request so that can't fail) |
| 61 | +//! let client = Client::new("http://localhost:7700", "masterKey"); |
| 62 | +//! |
| 63 | +//! // Get the index called "movies" |
| 64 | +//! let movies = client.get_or_create("movies").await.unwrap(); |
| 65 | +//! |
| 66 | +//! // Add some movies in the index |
| 67 | +//! movies.add_documents(&[ |
| 68 | +//! Movie{id: 1, title: String::from("Carol"), genres: vec!["Romance", "Drama"]}, |
| 69 | +//! Movie{id: 2, title: String::from("Wonder Woman"), genres: vec!["Action", "Adventure"]}, |
| 70 | +//! Movie{id: 3, title: String::from("Life of Pi"), genres: vec!["Adventure", "Drama"]}, |
| 71 | +//! Movie{id: 4, title: String::from("Mad Max"), genres: vec!["Adventure", "Science Fiction"]}, |
| 72 | +//! Movie{id: 5, title: String::from("Moana"), genres: vec!["Fantasy", "Action"]}, |
| 73 | +//! Movie{id: 6, title: String::from("Philadelphia"), genres: vec!["Drama"]}, |
| 74 | +//! ], Some("id")).await.unwrap(); |
| 75 | +//! |
| 76 | +//! // Query movies (note that there is a typo) |
| 77 | +//! println!("{:?}", movies.search().with_query("carol").execute::<Movie>().await.unwrap().hits); |
| 78 | +//! })} |
| 79 | +//! ``` |
| 80 | +//! |
| 81 | +//! Output: |
| 82 | +//! |
| 83 | +//! ```text |
| 84 | +//! [Movie{id: 1, title: String::from("Carol"), genres: vec!["Romance", "Drama"]}] |
| 85 | +//! ``` |
86 | 86 | //! |
87 | 87 | //! ## 🌐 Running in the Browser with WASM <!-- omit in TOC --> |
88 | 88 | //! |
|
0 commit comments