Struct meilisearch_sdk::indexes::Index
source · [−]pub struct Index { /* private fields */ }Expand description
An index containing [Document]s.
Example
You can create an index remotly and, if that succeed, make an Index out of it.
See the Client::create_index method.
let client = Client::new("http://localhost:7700", "masterKey");
// get the index called movies or create it if it does not exist
let movies = client
.create_index("index", None)
.await
.unwrap()
// We wait for the task to execute until completion
.wait_for_completion(&client, None, None)
.await
.unwrap()
// Once the task finished, we try to create an `Index` out of it
.try_make_index(&client)
.unwrap();
assert_eq!(movies.as_ref(), "index");Or, if you know the index already exist remotely you can create an Index with the Client::index function.
let client = Client::new("http://localhost:7700", "masterKey");
// use the implicit index creation if the index already exist or
// Meilisearch would be able to create the index if it does not exist during:
// - the documents addition (add and update routes)
// - the settings update
let movies = client.index("index");
// do something with the indexImplementations
sourceimpl Index
impl Index
sourcepub async fn update(&self, primary_key: impl AsRef<str>) -> Result<(), Error>
pub async fn update(&self, primary_key: impl AsRef<str>) -> Result<(), Error>
Set the primary key of the index.
If you prefer, you can use the method Index::set_primary_key, which is an alias.
sourcepub async fn delete(self) -> Result<Task, Error>
pub async fn delete(self) -> Result<Task, Error>
Delete the index.
Example
let client = Client::new("http://localhost:7700", "masterKey");
// get the index named "movies" and delete it
let index = client.index("delete");
let task = index.delete().await.unwrap();
client.wait_for_task(task, None, None).await.unwrap();sourcepub async fn execute_query<T: 'static + DeserializeOwned>(
&self,
query: &Query<'_>
) -> Result<SearchResults<T>, Error>
pub async fn execute_query<T: 'static + DeserializeOwned>(
&self,
query: &Query<'_>
) -> Result<SearchResults<T>, Error>
Search for documents matching a specific query in the index.
See also Index::search.
Example
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug)]
struct Movie {
name: String,
description: String,
}
let client = Client::new("http://localhost:7700", "masterKey");
let movies = client.index("execute_query");
// add some documents
let query = Query::new(&movies).with_query("Interstellar").with_limit(5).build();
let results = movies.execute_query::<Movie>(&query).await.unwrap();
assert!(results.hits.len()>0);sourcepub fn search(&self) -> Query<'_>
pub fn search(&self) -> Query<'_>
Search for documents matching a specific query in the index.
See also Index::execute_query.
Example
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug)]
struct Movie {
name: String,
description: String,
}
let client = Client::new("http://localhost:7700", "masterKey");
let mut movies = client.index("search");
// add some documents
let results = movies.search()
.with_query("Interstellar")
.with_limit(5)
.execute::<Movie>()
.await
.unwrap();
assert!(results.hits.len()>0);sourcepub async fn get_document<T: 'static + DeserializeOwned>(
&self,
uid: &str
) -> Result<T, Error>
pub async fn get_document<T: 'static + DeserializeOwned>(
&self,
uid: &str
) -> Result<T, Error>
Get one [Document] using its unique id.
Serde is needed. Add serde = {version="1.0", features=["derive"]} in the dependencies section of your Cargo.toml.
Example
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug)]
struct Movie {
name: String,
description: String,
}
let client = Client::new("http://localhost:7700", "masterKey");
let movies = client.index("get_documents");
// retrieve a document (you have to put the document in the index before)
let interstellar = movies.get_document::<Movie>("Interstellar").await.unwrap();
assert_eq!(interstellar, Movie {
name: String::from("Interstellar"),
description: String::from("Interstellar chronicles the adventures of a group of explorers who make use of a newly discovered wormhole to surpass the limitations on human space travel and conquer the vast distances involved in an interstellar voyage.")
});sourcepub async fn get_documents<T: DeserializeOwned + 'static>(
&self,
offset: Option<usize>,
limit: Option<usize>,
attributes_to_retrieve: Option<&str>
) -> Result<Vec<T>, Error>
pub async fn get_documents<T: DeserializeOwned + 'static>(
&self,
offset: Option<usize>,
limit: Option<usize>,
attributes_to_retrieve: Option<&str>
) -> Result<Vec<T>, Error>
Get [Document]s by batch.
Using the optional parameters offset and limit, you can browse through all your documents. If None, offset will be set to 0, limit to 20, and all attributes will be retrieved.
Note: Documents are ordered by Meilisearch depending on the hash of their id.
Example
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug)]
struct Movie {
name: String,
description: String,
}
let client = Client::new("http://localhost:7700", "masterKey");
let movie_index = client.index("get_documents");
// retrieve movies (you have to put some movies in the index before)
let movies = movie_index.get_documents::<Movie>(None, None, None).await.unwrap();
assert!(movies.len() > 0);sourcepub async fn add_or_replace<T: Serialize>(
&self,
documents: &[T],
primary_key: Option<&str>
) -> Result<Task, Error>
pub async fn add_or_replace<T: Serialize>(
&self,
documents: &[T],
primary_key: Option<&str>
) -> Result<Task, Error>
Add a list of [Document]s or replace them if they already exist.
If you send an already existing document (same id) the whole existing document will be overwritten by the new document. Fields previously in the document not present in the new document are removed.
For a partial update of the document see Index::add_or_update.
You can use the alias Index::add_documents if you prefer.
Example
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug)]
struct Movie {
name: String,
description: String,
}
let client = Client::new("http://localhost:7700", "masterKey");
let movie_index = client.index("add_or_replace");
let task = movie_index.add_or_replace(&[
Movie{
name: String::from("Interstellar"),
description: String::from("Interstellar chronicles the adventures of a group of explorers who make use of a newly discovered wormhole to surpass the limitations on human space travel and conquer the vast distances involved in an interstellar voyage.")
},
Movie{
// note that the id field can only take alphanumerics characters (and '-' and '/')
name: String::from("MrsDoubtfire"),
description: String::from("Loving but irresponsible dad Daniel Hillard, estranged from his exasperated spouse, is crushed by a court order allowing only weekly visits with his kids. When Daniel learns his ex needs a housekeeper, he gets the job -- disguised as an English nanny. Soon he becomes not only his children's best pal but the kind of parent he should have been from the start.")
},
Movie{
name: String::from("Apollo13"),
description: String::from("The true story of technical troubles that scuttle the Apollo 13 lunar mission in 1971, risking the lives of astronaut Jim Lovell and his crew, with the failed journey turning into a thrilling saga of heroism. Drifting more than 200,000 miles from Earth, the astronauts work furiously with the ground crew to avert tragedy.")
},
], Some("name")).await.unwrap();
// Meilisearch may take some time to execute the request so we are going to wait till it's completed
client.wait_for_task(task, None, None).await.unwrap();
let movies = movie_index.get_documents::<Movie>(None, None, None).await.unwrap();
assert!(movies.len() >= 3);sourcepub async fn add_documents<T: Serialize>(
&self,
documents: &[T],
primary_key: Option<&str>
) -> Result<Task, Error>
pub async fn add_documents<T: Serialize>(
&self,
documents: &[T],
primary_key: Option<&str>
) -> Result<Task, Error>
Alias for Index::add_or_replace.
sourcepub async fn add_or_update<T: Serialize>(
&self,
documents: &[T],
primary_key: Option<impl AsRef<str>>
) -> Result<Task, Error>
pub async fn add_or_update<T: Serialize>(
&self,
documents: &[T],
primary_key: Option<impl AsRef<str>>
) -> Result<Task, Error>
Add a list of documents and update them if they already.
If you send an already existing document (same id) the old document will be only partially updated according to the fields of the new document. Thus, any fields not present in the new document are kept and remained unchanged.
To completely overwrite a document, check out the Index::add_or_replace documents method.
Example
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug)]
struct Movie {
name: String,
description: String,
}
let client = Client::new("http://localhost:7700", "masterKey");
let movie_index = client.index("add_or_update");
let task = movie_index.add_or_update(&[
Movie {
name: String::from("Interstellar"),
description: String::from("Interstellar chronicles the adventures of a group of explorers who make use of a newly discovered wormhole to surpass the limitations on human space travel and conquer the vast distances involved in an interstellar voyage.")
},
Movie {
// note that the id field can only take alphanumerics characters (and '-' and '/')
name: String::from("MrsDoubtfire"),
description: String::from("Loving but irresponsible dad Daniel Hillard, estranged from his exasperated spouse, is crushed by a court order allowing only weekly visits with his kids. When Daniel learns his ex needs a housekeeper, he gets the job -- disguised as an English nanny. Soon he becomes not only his children's best pal but the kind of parent he should have been from the start.")
},
Movie {
name: String::from("Apollo13"),
description: String::from("The true story of technical troubles that scuttle the Apollo 13 lunar mission in 1971, risking the lives of astronaut Jim Lovell and his crew, with the failed journey turning into a thrilling saga of heroism. Drifting more than 200,000 miles from Earth, the astronauts work furiously with the ground crew to avert tragedy.")
},
], Some("name")).await.unwrap();
// Meilisearch may take some time to execute the request so we are going to wait till it's completed
client.wait_for_task(task, None, None).await.unwrap();
let movies = movie_index.get_documents::<Movie>(None, None, None).await.unwrap();
assert!(movies.len() >= 3);sourcepub async fn delete_all_documents(&self) -> Result<Task, Error>
pub async fn delete_all_documents(&self) -> Result<Task, Error>
Delete all documents in the index.
Example
let client = Client::new("http://localhost:7700", "masterKey");
let movie_index = client.index("delete_all_documents");
// add some documents
movie_index.delete_all_documents()
.await
.unwrap()
.wait_for_completion(&client, None, None)
.await
.unwrap();
let movies = movie_index.get_documents::<Movie>(None, None, None).await.unwrap();
assert_eq!(movies.len(), 0);sourcepub async fn delete_document<T: Display>(&self, uid: T) -> Result<Task, Error>
pub async fn delete_document<T: Display>(&self, uid: T) -> Result<Task, Error>
Delete one document based on its unique id.
Example
let client = Client::new("http://localhost:7700", "masterKey");
let mut movies = client.index("delete_document");
// add a document with id = Interstellar
movies.delete_document("Interstellar")
.await
.unwrap()
.wait_for_completion(&client, None, None)
.await
.unwrap();sourcepub async fn delete_documents<T: Display + Serialize + Debug>(
&self,
uids: &[T]
) -> Result<Task, Error>
pub async fn delete_documents<T: Display + Serialize + Debug>(
&self,
uids: &[T]
) -> Result<Task, Error>
Delete a selection of documents based on array of document id’s.
Example
let client = Client::new("http://localhost:7700", "masterKey");
let movies = client.index("delete_documents");
// add some documents
// delete some documents
movies.delete_documents(&["Interstellar", "Unknown"])
.await
.unwrap()
.wait_for_completion(&client, None, None)
.await
.unwrap();sourcepub async fn set_primary_key(
&self,
primary_key: impl AsRef<str>
) -> Result<(), Error>
pub async fn set_primary_key(
&self,
primary_key: impl AsRef<str>
) -> Result<(), Error>
Alias for the Index::update method.
sourcepub async fn fetch_info(&self) -> Result<JsonIndex, Error>
pub async fn fetch_info(&self) -> Result<JsonIndex, Error>
Fetch the information of the index as a raw JSON Index, this index should already exist.
Example
// create the client
let client = Client::new("http://localhost:7700", "masterKey");
// get the information of the index named "fetch_info"
let movies = client.index("fetch_info").fetch_info().await.unwrap();If you use it directly from the Client, you can use the method Client::get_raw_index, which is the equivalent method from the client.
sourcepub async fn get_primary_key(&self) -> Result<Option<String>, Error>
pub async fn get_primary_key(&self) -> Result<Option<String>, Error>
Fetch the primary key of the index.
Example
// create the client
let client = Client::new("http://localhost:7700", "masterKey");
// get the primary key of the index named "movies"
let movies = client.index("movies").get_primary_key().await;sourcepub async fn get_task(&self, uid: impl AsRef<u64>) -> Result<Task, Error>
pub async fn get_task(&self, uid: impl AsRef<u64>) -> Result<Task, Error>
Get a Task from a specific Index to keep track of asynchronous operations.
Example
let client = Client::new("http://localhost:7700", "masterKey");
let movies = client.index("get_task");
let task = movies.add_documents(&[
Document { id: 0, kind: "title".into(), value: "The Social Network".to_string() }
], None).await.unwrap();
// Get task status from the index, using `uid`
let status = movies.get_task(&task).await.unwrap();
let from_index = match status {
Task::Enqueued { content } => content.uid,
Task::Processing { content } => content.uid,
Task::Failed { content } => content.task.uid,
Task::Succeeded { content } => content.uid,
};
assert_eq!(task.get_uid(), from_index);sourcepub async fn get_tasks(&self) -> Result<Vec<Task>, Error>
pub async fn get_tasks(&self) -> Result<Vec<Task>, Error>
Get the status of all tasks in a given index.
Example
let status = index.get_tasks().await.unwrap();
assert!(status.len() == 1); // the index was created
index.set_ranking_rules(["wrong_ranking_rule"]).await.unwrap();
let status = index.get_tasks().await.unwrap();
assert!(status.len() == 2);sourcepub async fn get_stats(&self) -> Result<IndexStats, Error>
pub async fn get_stats(&self) -> Result<IndexStats, Error>
Get stats of an index.
Example
let stats = index.get_stats().await.unwrap();
assert_eq!(stats.is_indexing, false);sourcepub async fn wait_for_task(
&self,
task_id: impl AsRef<u64>,
interval: Option<Duration>,
timeout: Option<Duration>
) -> Result<Task, Error>
pub async fn wait_for_task(
&self,
task_id: impl AsRef<u64>,
interval: Option<Duration>,
timeout: Option<Duration>
) -> Result<Task, Error>
Wait until Meilisearch processes a Task, and get its status.
interval = The frequency at which the server should be polled. Default = 50ms
timeout = The maximum time to wait for processing to complete. Default = 5000ms
If the waited time exceeds timeout then an Error::Timeout will be returned.
See also [Client::wait_for_task, Task::wait_for_completion].
Example
let client = Client::new("http://localhost:7700", "masterKey");
let movies = client.index("movies_index_wait_for_task");
let task = movies.add_documents(&[
Document { id: 0, kind: "title".into(), value: "The Social Network".to_string() },
Document { id: 1, kind: "title".into(), value: "Harry Potter and the Sorcerer's Stone".to_string() },
], None).await.unwrap();
let status = movies.wait_for_task(task, None, None).await.unwrap();
assert!(matches!(status, Task::Succeeded { .. }));sourcepub async fn add_documents_in_batches<T: Serialize>(
&self,
documents: &[T],
batch_size: Option<usize>,
primary_key: Option<&str>
) -> Result<Vec<Task>, Error>
pub async fn add_documents_in_batches<T: Serialize>(
&self,
documents: &[T],
batch_size: Option<usize>,
primary_key: Option<&str>
) -> Result<Vec<Task>, Error>
Add documents to the index in batches
documents = A slice of documents
batch_size = Optional parameter that allows you to specify the size of the batch
batch_size is 1000 by default
Example
use serde::{Serialize, Deserialize};
use meilisearch_sdk::client::*;
#[derive(Serialize, Deserialize, Debug)]
struct Movie {
name: String,
description: String,
}
let client = Client::new("http://localhost:7700", "masterKey");
let movie_index = client.index("add_documents_in_batches");
let tasks = movie_index.add_documents_in_batches(&[
Movie {
name: String::from("Interstellar"),
description: String::from("Interstellar chronicles the adventures of a group of explorers who make use of a newly discovered wormhole to surpass the limitations on human space travel and conquer the vast distances involved in an interstellar voyage.")
},
Movie {
// note that the id field can only take alphanumerics characters (and '-' and '/')
name: String::from("MrsDoubtfire"),
description: String::from("Loving but irresponsible dad Daniel Hillard, estranged from his exasperated spouse, is crushed by a court order allowing only weekly visits with his kids. When Daniel learns his ex needs a housekeeper, he gets the job -- disguised as an English nanny. Soon he becomes not only his children's best pal but the kind of parent he should have been from the start.")
},
Movie {
name: String::from("Apollo13"),
description: String::from("The true story of technical troubles that scuttle the Apollo 13 lunar mission in 1971, risking the lives of astronaut Jim Lovell and his crew, with the failed journey turning into a thrilling saga of heroism. Drifting more than 200,000 miles from Earth, the astronauts work furiously with the ground crew to avert tragedy.")
}],
Some(1),
Some("name")
).await.unwrap();
client.wait_for_task(tasks.last().unwrap(), None, None).await.unwrap();
let movies = movie_index.get_documents::<Movie>(None, None, None).await.unwrap();
assert!(movies.len() >= 3);
None).await.unwrap();sourcepub async fn update_documents_in_batches<T: Serialize>(
&self,
documents: &[T],
batch_size: Option<usize>,
primary_key: Option<&str>
) -> Result<Vec<Task>, Error>
pub async fn update_documents_in_batches<T: Serialize>(
&self,
documents: &[T],
batch_size: Option<usize>,
primary_key: Option<&str>
) -> Result<Vec<Task>, Error>
Update documents to the index in batches
documents = A slice of documents
batch_size = Optional parameter that allows you to specify the size of the batch
batch_size is 1000 by default
Example
use serde::{Serialize, Deserialize};
use meilisearch_sdk::client::*;
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
struct Movie {
name: String,
description: String,
}
let client = Client::new("http://localhost:7700", "masterKey");
let movie_index = client.index("update_documents_in_batches");
let tasks = movie_index.add_documents_in_batches(&[
Movie {
name: String::from("Interstellar"),
description: String::from("Interstellar chronicles the adventures of a group of explorers who make use of a newly discovered wormhole to surpass the limitations on human space travel and conquer the vast distances involved in an interstellar voyage.")
},
Movie {
// note that the id field can only take alphanumerics characters (and '-' and '/')
name: String::from("MrsDoubtfire"),
description: String::from("Loving but irresponsible dad Daniel Hillard, estranged from his exasperated spouse, is crushed by a court order allowing only weekly visits with his kids. When Daniel learns his ex needs a housekeeper, he gets the job -- disguised as an English nanny. Soon he becomes not only his children's best pal but the kind of parent he should have been from the start.")
},
Movie {
name: String::from("Apollo13"),
description: String::from("The true story of technical troubles that scuttle the Apollo 13 lunar mission in 1971, risking the lives of astronaut Jim Lovell and his crew, with the failed journey turning into a thrilling saga of heroism. Drifting more than 200,000 miles from Earth, the astronauts work furiously with the ground crew to avert tragedy.")
}],
Some(1),
Some("name")
).await.unwrap();
client.wait_for_task(tasks.last().unwrap(), None, None).await.unwrap();
let movies = movie_index.get_documents::<Movie>(None, None, None).await.unwrap();
assert!(movies.len() >= 3);
let updated_movies = [
Movie {
name: String::from("Interstellar"),
description: String::from("Updated!")
},
Movie {
// note that the id field can only take alphanumerics characters (and '-' and '/')
name: String::from("MrsDoubtfire"),
description: String::from("Updated!")
},
Movie {
name: String::from("Apollo13"),
description: String::from("Updated!")
}];
let tasks = movie_index.update_documents_in_batches(&updated_movies, Some(1), None).await.unwrap();
client.wait_for_task(tasks.last().unwrap(), None, None).await.unwrap();
let movies_updated = movie_index.get_documents::<Movie>(None, None, None).await.unwrap();
assert!(movies_updated.len() >= 3);
assert!(&movies_updated[..] == &updated_movies[..]);
None).await.unwrap();sourceimpl Index
impl Index
sourcepub async fn get_settings(&self) -> Result<Settings, Error>
pub async fn get_settings(&self) -> Result<Settings, Error>
sourcepub async fn get_stop_words(&self) -> Result<Vec<String>, Error>
pub async fn get_stop_words(&self) -> Result<Vec<String>, Error>
Get stop-words of the Index.
let client = Client::new("http://localhost:7700", "masterKey");
let index = client.index("get_stop_words");
let stop_words = index.get_stop_words().await.unwrap();sourcepub async fn get_ranking_rules(&self) -> Result<Vec<String>, Error>
pub async fn get_ranking_rules(&self) -> Result<Vec<String>, Error>
Get ranking rules of the Index.
let client = Client::new("http://localhost:7700", "masterKey");
let index = client.index("get_ranking_rules");
let ranking_rules = index.get_ranking_rules().await.unwrap();sourcepub async fn get_filterable_attributes(&self) -> Result<Vec<String>, Error>
pub async fn get_filterable_attributes(&self) -> Result<Vec<String>, Error>
Get filterable attributes of the Index.
let client = Client::new("http://localhost:7700", "masterKey");
let index = client.index("get_filterable_attributes");
let filterable_attributes = index.get_filterable_attributes().await.unwrap();sourcepub async fn get_sortable_attributes(&self) -> Result<Vec<String>, Error>
pub async fn get_sortable_attributes(&self) -> Result<Vec<String>, Error>
Get sortable attributes of the Index.
let client = Client::new("http://localhost:7700", "masterKey");
let index = client.index("get_sortable_attributes");
let sortable_attributes = index.get_sortable_attributes().await.unwrap();sourcepub async fn get_distinct_attribute(&self) -> Result<Option<String>, Error>
pub async fn get_distinct_attribute(&self) -> Result<Option<String>, Error>
Get the distinct attribute of the Index.
let client = Client::new("http://localhost:7700", "masterKey");
let index = client.index("get_distinct_attribute");
let distinct_attribute = index.get_distinct_attribute().await.unwrap();sourcepub async fn get_searchable_attributes(&self) -> Result<Vec<String>, Error>
pub async fn get_searchable_attributes(&self) -> Result<Vec<String>, Error>
Get searchable attributes of the Index.
let client = Client::new("http://localhost:7700", "masterKey");
let index = client.index("get_searchable_attributes");
let searchable_attributes = index.get_searchable_attributes().await.unwrap();sourcepub async fn get_displayed_attributes(&self) -> Result<Vec<String>, Error>
pub async fn get_displayed_attributes(&self) -> Result<Vec<String>, Error>
Get displayed attributes of the Index.
let client = Client::new("http://localhost:7700", "masterKey");
let index = client.index("get_displayed_attributes");
let displayed_attributes = index.get_displayed_attributes().await.unwrap();sourcepub async fn set_settings(&self, settings: &Settings) -> Result<Task, Error>
pub async fn set_settings(&self, settings: &Settings) -> Result<Task, Error>
Update settings of the Index.
Updates in the settings are partial. This means that any parameters corresponding to a None value will be left unchanged.
Example
let client = Client::new("http://localhost:7700", "masterKey");
let mut index = client.index("set_settings");
let stop_words = vec![String::from("a"), String::from("the"), String::from("of")];
let settings = Settings::new()
.with_stop_words(stop_words.clone());
let task = index.set_settings(&settings).await.unwrap();sourcepub async fn set_synonyms(
&self,
synonyms: &HashMap<String, Vec<String>>
) -> Result<Task, Error>
pub async fn set_synonyms(
&self,
synonyms: &HashMap<String, Vec<String>>
) -> Result<Task, Error>
Example
let client = Client::new("http://localhost:7700", "masterKey");
let mut index = client.index("set_synonyms");
let mut synonyms = std::collections::HashMap::new();
synonyms.insert(String::from("wolverine"), vec![String::from("xmen"), String::from("logan")]);
synonyms.insert(String::from("logan"), vec![String::from("xmen"), String::from("wolverine")]);
synonyms.insert(String::from("wow"), vec![String::from("world of warcraft")]);
let task = index.set_synonyms(&synonyms).await.unwrap();sourcepub async fn set_stop_words(
&self,
stop_words: impl IntoIterator<Item = impl AsRef<str>>
) -> Result<Task, Error>
pub async fn set_stop_words(
&self,
stop_words: impl IntoIterator<Item = impl AsRef<str>>
) -> Result<Task, Error>
Update stop-words of the Index.
Example
let client = Client::new("http://localhost:7700", "masterKey");
let mut index = client.index("set_stop_words");
let stop_words = ["the", "of", "to"];
let task = index.set_stop_words(&stop_words).await.unwrap();sourcepub async fn set_ranking_rules(
&self,
ranking_rules: impl IntoIterator<Item = impl AsRef<str>>
) -> Result<Task, Error>
pub async fn set_ranking_rules(
&self,
ranking_rules: impl IntoIterator<Item = impl AsRef<str>>
) -> Result<Task, Error>
Update ranking rules of the Index.
Example
let client = Client::new("http://localhost:7700", "masterKey");
let mut index = client.index("set_ranking_rules");
let ranking_rules = [
"words",
"typo",
"proximity",
"attribute",
"sort",
"exactness",
"release_date:asc",
"rank:desc",
];
let task = index.set_ranking_rules(ranking_rules).await.unwrap();sourcepub async fn set_filterable_attributes(
&self,
filterable_attributes: impl IntoIterator<Item = impl AsRef<str>>
) -> Result<Task, Error>
pub async fn set_filterable_attributes(
&self,
filterable_attributes: impl IntoIterator<Item = impl AsRef<str>>
) -> Result<Task, Error>
Update filterable attributes of the Index.
Example
let client = Client::new("http://localhost:7700", "masterKey");
let mut index = client.index("set_filterable_attributes");
let filterable_attributes = ["genre", "director"];
let task = index.set_filterable_attributes(&filterable_attributes).await.unwrap();sourcepub async fn set_sortable_attributes(
&self,
sortable_attributes: impl IntoIterator<Item = impl AsRef<str>>
) -> Result<Task, Error>
pub async fn set_sortable_attributes(
&self,
sortable_attributes: impl IntoIterator<Item = impl AsRef<str>>
) -> Result<Task, Error>
Update sortable attributes of the Index.
Example
let client = Client::new("http://localhost:7700", "masterKey");
let mut index = client.index("set_sortable_attributes");
let sortable_attributes = ["genre", "director"];
let task = index.set_sortable_attributes(&sortable_attributes).await.unwrap();sourcepub async fn set_distinct_attribute(
&self,
distinct_attribute: impl AsRef<str>
) -> Result<Task, Error>
pub async fn set_distinct_attribute(
&self,
distinct_attribute: impl AsRef<str>
) -> Result<Task, Error>
Update the distinct attribute of the Index.
Example
let client = Client::new("http://localhost:7700", "masterKey");
let mut index = client.index("set_distinct_attribute");
let task = index.set_distinct_attribute("movie_id").await.unwrap();sourcepub async fn set_searchable_attributes(
&self,
searchable_attributes: impl IntoIterator<Item = impl AsRef<str>>
) -> Result<Task, Error>
pub async fn set_searchable_attributes(
&self,
searchable_attributes: impl IntoIterator<Item = impl AsRef<str>>
) -> Result<Task, Error>
Update searchable attributes of the Index.
Example
let client = Client::new("http://localhost:7700", "masterKey");
let mut index = client.index("set_searchable_attributes");
let task = index.set_searchable_attributes(["title", "description", "uid"]).await.unwrap();sourcepub async fn set_displayed_attributes(
&self,
displayed_attributes: impl IntoIterator<Item = impl AsRef<str>>
) -> Result<Task, Error>
pub async fn set_displayed_attributes(
&self,
displayed_attributes: impl IntoIterator<Item = impl AsRef<str>>
) -> Result<Task, Error>
Update displayed attributes of the Index.
Example
let client = Client::new("http://localhost:7700", "masterKey");
let mut index = client.index("set_displayed_attributes");
let task = index.set_displayed_attributes(["title", "description", "release_date", "rank", "poster"]).await.unwrap();sourcepub async fn reset_settings(&self) -> Result<Task, Error>
pub async fn reset_settings(&self) -> Result<Task, Error>
Reset Settings of the Index. All settings will be reset to their default value.
Example
let client = Client::new("http://localhost:7700", "masterKey");
let mut index = client.index("reset_settings");
let task = index.reset_settings().await.unwrap();sourcepub async fn reset_synonyms(&self) -> Result<Task, Error>
pub async fn reset_synonyms(&self) -> Result<Task, Error>
sourcepub async fn reset_stop_words(&self) -> Result<Task, Error>
pub async fn reset_stop_words(&self) -> Result<Task, Error>
Reset stop-words of the Index.
Example
let client = Client::new("http://localhost:7700", "masterKey");
let mut index = client.index("reset_stop_words");
let task = index.reset_stop_words().await.unwrap();sourcepub async fn reset_ranking_rules(&self) -> Result<Task, Error>
pub async fn reset_ranking_rules(&self) -> Result<Task, Error>
Reset ranking rules of the Index to default value.
Default value: ["words", "typo", "proximity", "attribute", "sort", "exactness"].
Example
let client = Client::new("http://localhost:7700", "masterKey");
let mut index = client.index("reset_ranking_rules");
let task = index.reset_ranking_rules().await.unwrap();sourcepub async fn reset_filterable_attributes(&self) -> Result<Task, Error>
pub async fn reset_filterable_attributes(&self) -> Result<Task, Error>
Reset filterable attributes of the Index.
Example
let client = Client::new("http://localhost:7700", "masterKey");
let mut index = client.index("reset_filterable_attributes");
let task = index.reset_filterable_attributes().await.unwrap();sourcepub async fn reset_sortable_attributes(&self) -> Result<Task, Error>
pub async fn reset_sortable_attributes(&self) -> Result<Task, Error>
Reset sortable attributes of the Index.
Example
let client = Client::new("http://localhost:7700", "masterKey");
let mut index = client.index("reset_sortable_attributes");
let task = index.reset_sortable_attributes().await.unwrap();sourcepub async fn reset_distinct_attribute(&self) -> Result<Task, Error>
pub async fn reset_distinct_attribute(&self) -> Result<Task, Error>
Reset the distinct attribute of the Index.
Example
let client = Client::new("http://localhost:7700", "masterKey");
let mut index = client.index("reset_distinct_attribute");
let task = index.reset_distinct_attribute().await.unwrap();sourcepub async fn reset_searchable_attributes(&self) -> Result<Task, Error>
pub async fn reset_searchable_attributes(&self) -> Result<Task, Error>
Reset searchable attributes of the Index (enable all attributes).
Example
let client = Client::new("http://localhost:7700", "masterKey");
let mut index = client.index("reset_searchable_attributes");
let task = index.reset_searchable_attributes().await.unwrap();sourcepub async fn reset_displayed_attributes(&self) -> Result<Task, Error>
pub async fn reset_displayed_attributes(&self) -> Result<Task, Error>
Reset displayed attributes of the Index (enable all attributes).
Example
let client = Client::new("http://localhost:7700", "masterKey");
let mut index = client.index("reset_displayed_attributes");
let task = index.reset_displayed_attributes().await.unwrap();Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Index
impl Send for Index
impl Sync for Index
impl Unpin for Index
impl UnwindSafe for Index
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more