Crate heroindex_client

Crate heroindex_client 

Source
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§

BatchAddResult
Batch add result.
CloseResult
Close database result.
CountResult
Count result.
CreateResult
Create result.
DatabaseInfo
Database information.
DatabaseList
Database list response.
ExitResult
Exit/shutdown result.
FieldInfo
Field information.
HeroIndexClient
HeroIndex client for connecting to a HeroIndex server.
OpResult
Operation result with opstamp.
PingResponse
Server ping response.
SchemaInfo
Schema information.
SearchHit
A single search hit.
SearchResult
Search result.
SelectResult
Select result.
ServerStats
Server statistics.
SuccessResult
Simple success result.

Enums§

Error
Client error type.