[−][src]Struct meilisearch_sdk::client::Client
The top-level struct of the SDK, representing a client containing indexes.
Implementations
impl<'a> Client<'a>
[src]
pub const fn new(host: &'a str, apikey: &'a str) -> Client<'a>
[src]
Create a client using the specified server. Don't put a '/' at the end of the host. In production mode, see the documentation about authentication.
Example
// create the client let client = Client::new("http://localhost:7700", "masterKey");
pub async fn list_all_indexes(&'a self) -> Result<Vec<Index<'a>>, Error>
[src]
List all indexes.
Example
// create the client let client = Client::new("http://localhost:7700", "masterKey"); let indexes: Vec<Index> = client.list_all_indexes().await.unwrap(); println!("{:?}", indexes);
pub async fn get_index(&'a self, uid: &'a str) -> Result<Index<'a>, Error>
[src]
Get an index.
Example
// create the client let client = Client::new("http://localhost:7700", "masterKey"); // get the index named "movies" let movies = client.get_index("movies").await.unwrap();
pub fn assume_index(&'a self, uid: &'a str) -> Index<'a>
[src]
Assume that an index exist and create a corresponding object without any check.
pub async fn create_index<'_>(
&'a self,
uid: &'a str,
primary_key: Option<&'_ str>
) -> Result<Index<'a>, Error>
[src]
&'a self,
uid: &'a str,
primary_key: Option<&'_ str>
) -> Result<Index<'a>, Error>
Create an index. The second parameter will be used as the primary key of the new index. If it is not specified, MeiliSearch will try to infer the primary key.
Example
// create the client let client = Client::new("http://localhost:7700", "masterKey"); // create a new index called movies and access it let movies = client.create_index("movies", None).await;
pub async fn delete_index<'_, '_>(&'_ self, uid: &'_ str) -> Result<(), Error>
[src]
Delete an index from its UID. To delete an index from the index object, use the delete method.
pub async fn get_or_create(&'a self, uid: &'a str) -> Result<Index<'a>, Error>
[src]
This will try to get an index and create the index if it does not exist.
pub async fn get_indexes(&'a self) -> Result<Vec<Index<'a>>, Error>
[src]
Alias for list_all_indexes.
pub async fn get_stats<'_>(&'_ self) -> Result<ClientStats, Error>
[src]
Get stats of all indexes.
Example
let client = Client::new("http://localhost:7700", "masterKey"); let stats = client.get_stats().await.unwrap();
pub async fn get_health<'_>(&'_ self) -> Result<(), Error>
[src]
Get health of MeiliSearch server.
Example
let client = Client::new("http://localhost:7700", "masterKey"); match client.get_health().await { Ok(()) => println!("server is operational"), Err(Error::MeiliSearchError { error_code: ErrorCode::Maintenance, .. }) => { eprintln!("server is in maintenance") }, Err(e) => panic!("should never happen: {}", e), }
pub async fn set_health<'_>(&'_ self, health: bool) -> Result<(), Error>
[src]
Update health of MeiliSearch server.
Example
let client = Client::new("http://localhost:7700", "masterKey"); client.set_health(false).await.unwrap();
pub async fn get_version<'_>(&'_ self) -> Result<Version, Error>
[src]
Get version of the MeiliSearch server.
Example
let client = Client::new("http://localhost:7700", "masterKey"); let version = client.get_version().await.unwrap();
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for Client<'a>
impl<'a> Send for Client<'a>
impl<'a> Sync for Client<'a>
impl<'a> Unpin for Client<'a>
impl<'a> UnwindSafe for Client<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,