Crates.io | algoliasearch |
lib.rs | algoliasearch |
version | 0.1.7 |
source | src |
created_at | 2019-04-06 14:38:54.69879 |
updated_at | 2024-05-03 09:37:37.383136 |
description | Algolia client |
homepage | https://github.com/nicompte/algoliasearch-rs |
repository | https://github.com/nicompte/algoliasearch-rs |
max_upload_size | |
id | 126165 |
size | 75,547 |
algoliasearch
is a (really incomplete) rust implemention of an algolia client.
use algoliasearch::Client;
// needs tokio as a dependency,
// tokio = { version = "1", features = ["macros", "rt", "rt-multi-thread"] }
use tokio;
#[derive(Deserialize)]
struct User {
name: String,
age: u32,
}
#[tokio::main]
async fn main() -> Result<(), Box<Error>> {
// read ALGOLIA_APPLICATION_ID and ALGOLIA_API_KEY from env
let index = Client::default().init_index::<User>("users");
let res = index.search("Bernardo").await?;
dbg!(res.hits); // [User { name: "Bernardo", age: 32} ]
Ok(())
}