use meilisearch_sdk::{client::Client, indexes::Index, settings::Settings};
#[tokio::main(flavor = "current_thread")]
async fn main() {
let client: Client = Client::new("http://localhost:7700", Some("masterKey")).unwrap();
let my_index: Index = client
.create_index("movies", Some("movie_id"))
.await
.expect("Could not join the remote server.")
.wait_for_completion(&client, None, None)
.await
.expect("Could not join the remote server.")
.try_make_index(&client)
.expect("An error happened with the index creation.");
let settings: Settings = Settings::new()
.with_searchable_attributes(["name", "title"])
.with_filterable_attributes(["created_at"]);
let task = my_index
.set_settings(&settings)
.await
.expect("Could not join the remote server.")
.wait_for_completion(&client, None, None)
.await
.expect("Could not join the remote server.");
assert!(
!task.is_failure(),
"Could not update the settings. {}",
task.unwrap_failure().error_message
);
my_index
.delete()
.await
.expect("Could not join the remote server.")
.wait_for_completion(&client, None, None)
.await
.expect("Could not join the remote server.");
assert!(
!task.is_failure(),
"Could not delete the index. {}",
task.unwrap_failure().error_message
);
}