Expand description
HeroIndex Client Library
A lightweight client library for connecting to HeroIndex search servers.
§Example
use heroindex_client::HeroIndexClient;
#[tokio::main]
async fn main() -> Result<(), heroindex_client::Error> {
let mut client = HeroIndexClient::connect("/tmp/heroindex.sock").await?;
// Ping the server
let info = client.ping().await?;
println!("Server version: {}", info.version);
// Create a database
client.db_create("articles", serde_json::json!({
"fields": [
{"name": "title", "type": "text", "stored": true, "indexed": true},
{"name": "body", "type": "text", "stored": true, "indexed": true}
]
})).await?;
// Select and use the database
client.db_select("articles").await?;
// Add documents
client.doc_add(serde_json::json!({
"title": "Hello World",
"body": "This is my first article"
})).await?;
client.commit().await?;
client.reload().await?;
// Search
let results = client.search(
serde_json::json!({"type": "match", "field": "body", "value": "first"}),
10,
0
).await?;
println!("Found {} results", results.total_hits);
Ok(())
}Structs§
- Batch
AddResult - Batch add result.
- Close
Result - Close database result.
- Count
Result - Count result.
- Create
Result - Create result.
- Database
Info - Database information.
- Database
List - Database list response.
- Exit
Result - Exit/shutdown result.
- Field
Info - Field information.
- Hero
Index Client - HeroIndex client for connecting to a HeroIndex server.
- OpResult
- Operation result with opstamp.
- Ping
Response - Server ping response.
- Schema
Info - Schema information.
- Search
Hit - A single search hit.
- Search
Result - Search result.
- Select
Result - Select result.
- Server
Stats - Server statistics.
- Success
Result - Simple success result.
Enums§
- Error
- Client error type.