Struct meilisearch_sdk::client::Client[][src]

pub struct Client { /* fields omitted */ }
Expand description

The top-level struct of the SDK, representing a client containing indexes.

Implementations

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");

List all [indexes] and returns values as instances of Index(../indexes/struct.Index.html).

Example
// create the client
let client = Client::new("http://localhost:7700", "masterKey");

let indexes: Vec<Index> = client.list_all_indexes().await.unwrap();
println!("{:?}", indexes);

List all [indexes] and returns as Json (../indexes/struct.Index.html).

Example
// create the client
let client = Client::new("http://localhost:7700", "masterKey");

let json_indexes: Vec<JsonIndex> = client.list_all_indexes_raw().await.unwrap();
println!("{:?}", json_indexes);

Get an index, this index should already exist.

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();

Get a raw JSON index, this index should already exist.

Example

// create the client
let client = Client::new("http://localhost:7700", "masterKey");

// get the index named "movies"
let movies = client.get_raw_index("movies").await.unwrap();

If you use it directly from an index, you can use the method fetch_info, which is the equivalent method from an index.

Create a corresponding object of an index without any check or doing an HTTP call.

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;

Delete an index from its UID if it exists. To delete an index if it exists from the Index object, use the Index::delete_if_exists method.

Delete an index from its UID. To delete an index from the index object, use the delete method.

This will try to get an index and create the index if it does not exist.

Alias for list_all_indexes.

Get stats of all indexes.

Example
let client = Client::new("http://localhost:7700", "masterKey");
let stats = client.get_stats().await.unwrap();

Get health of MeiliSearch server.

Example
let client = Client::new("http://localhost:7700", "masterKey");
let health = client.health().await.unwrap();

Get health of MeiliSearch server, return true or false.

Example
let client = Client::new("http://localhost:7700", "masterKey");
let health = client.is_healthy().await;
assert_eq!(health, true);

Get the private and public key.

Example
let client = Client::new("http://localhost:7700", "masterKey");
let keys = client.get_keys().await.unwrap();

Get version of the MeiliSearch server.

Example
let client = Client::new("http://localhost:7700", "masterKey");
let version = client.get_version().await.unwrap();

Dump related methods.
See the dumps module.

Triggers a dump creation process. Once the process is complete, a dump is created in the dumps directory. If the dumps directory does not exist yet, it will be created.

Example
let dump_info = client.create_dump().await.unwrap();
assert!(matches!(dump_info.status, DumpStatus::InProgress));

Get the status of a dump creation process using the uid returned after calling the dump creation method.

Example
let dump_info = client.get_dump_status(&dump_info.uid).await.unwrap();

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more