[][src]Struct meilimelo::MeiliMelo

pub struct MeiliMelo<'m> { /* fields omitted */ }

Descriptor to a MeiliSearch instance

Implementations

impl<'m> MeiliMelo<'m>[src]

pub fn new(host: &str) -> MeiliMelo<'_>[src]

Creates a new descriptor to a MeiliSearch instance

Arguments

  • host - Scheme, hostname and port to the MeiliSearch instance

pub fn with_secret_key(self, key: &'m str) -> MeiliMelo<'m>[src]

Adds the secret key to be used to authenticate against MeiliSearch

Arguments

  • key - The string representation of the secret key

Examples

use meilimelo::prelude::*;

let m = MeiliMelo::new("https://meilisearch.example.com:7700")
  .with_secret_key("abcdef");

pub fn search(&'m self, index: &'m str) -> Query<'_>[src]

Initialize a search query

The returned struct implements the builder pattern and allows to construct the query incrementally. Please see Query for details on the available methods.

Arguments

  • index - The name of the index to search

pub async fn indices(&'m self) -> Result<Vec<Index>, Error>[src]

List all available indices

Examples

let meili = MeiliMelo::new("host");

for index in meili.indices().await.unwrap() {
  println!("{}", index.name);
}

pub async fn create_index<'a, '_, '_>(
    &'m self,
    uid: &'_ str,
    name: &'_ str
) -> Result<Index, Error>
[src]

Create a new index

Arguments

  • uid - unique ID for the new index
  • name - human-readable name for the index

Examples

MeiliMelo::new("host")
  .create_index("employees", "Employees")
  .await;

pub async fn delete_index<'_>(&'m self, uid: &'_ str) -> Result<(), Error>[src]

Delete an existing index

Arguments

  • uid - unique ID to the index to be deleted

Examples

MeiliMelo::new("host")
  .delete_index("employees")
  .await;

pub async fn insert<T, '_, '_>(
    &'m self,
    index: &'_ str,
    documents: &'_ Vec<T>
) -> Result<Update, Error> where
    T: Serialize
[src]

Index a collection of documents into MeiliSearch

Arguments

  • index - Name of the index into which documents are to be inserted
  • documents - Collection of Serialize-able structs to insert

Examples

let docs = vec![
  Employee { firstname: "Luke".to_string(), lastname: "Skywalker".to_string() }
];

MeiliMelo::new("host")
  .insert("employees", &docs);

pub async fn list_documents<R, '_>(
    &'m self,
    index: &'_ str,
    limit: i64,
    offset: i64
) -> Result<Vec<R>, Error> where
    R: Deserialize<'de>, 
[src]

List documents in order

Arguments

  • index - name of the index to browse
  • limit - number of documents to return
  • offset - offset to the first document to return

Examples

let meili = MeiliMelo::new("host");

for document in &meili.list_documents::<Employee>("employees", 10, 0).await.unwrap() {
  println!("{} {}", document.firstname, document.lastname);
}

pub async fn get_document<R, '_, '_>(
    &'m self,
    index: &'_ str,
    uid: &'_ str
) -> Result<R, Error> where
    R: Deserialize<'de>, 
[src]

List documents in order

Arguments

  • index - name of the index to browse
  • uid - Unique ID of the document to return

Examples

MeiliMelo::new("")
  .get_document::<Employee>("employees", "lskywalker")
  .await;

pub async fn delete_document<'_, '_>(
    &'m self,
    index: &'_ str,
    uid: &'_ str
) -> Result<Update, Error>
[src]

Delete a document

Arguments

  • uid - Unique ID of the document to delete

Examples

MeiliMelo::new("host")
  .delete_document("employees", "lskywalker")
  .await;

Trait Implementations

impl<'m> Debug for MeiliMelo<'m>[src]

impl<'m> Default for MeiliMelo<'m>[src]

Auto Trait Implementations

impl<'m> RefUnwindSafe for MeiliMelo<'m>

impl<'m> Send for MeiliMelo<'m>

impl<'m> Sync for MeiliMelo<'m>

impl<'m> Unpin for MeiliMelo<'m>

impl<'m> UnwindSafe for MeiliMelo<'m>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.