Rust client for sonic search backend
Find a file
2022-03-23 23:45:54 +03:00
.github/ISSUE_TEMPLATE chore: update issue templates 2020-11-14 02:48:37 +03:00
src refac: prevent a panic 2022-03-23 23:45:54 +03:00
tests tests(integration/query): add limited 2021-12-25 00:24:20 +03:00
.gitignore chore: remove main file from repo 2020-07-18 14:59:15 +03:00
Cargo.toml use greyblake/whatlang-rs to autodect locale 2022-03-23 22:33:11 +02:00
CODE_OF_CONDUCT.md chore: add code of conduct 2021-02-12 01:38:32 +03:00
docker-compose.test.yml tests(integration): add tests for push and query 2021-12-24 17:15:54 +03:00
LICENSE Initial commit 2020-07-18 10:59:02 +03:00
README.md fix(doc): typo in features block 2022-03-23 23:34:33 +03:00
sonic.cfg tests(integration): add tests for push and query 2021-12-24 17:15:54 +03:00

Sonic Channel

Rust client for sonic search backend.

We recommend you start with the documentation.

Installation

Add sonic-channel = { version = "0.5" } as a dependency in Cargo.toml.

Cargo.toml example:

[package]
name = "my-crate"
version = "0.1.0"
authors = ["Me <user@rust-lang.org>"]

[dependencies]
sonic-channel = { version = "0.5" }

Example usage

Search channel

Note: This example requires enabling the search feature, enabled by default.

use sonic_channel::*;

fn main() -> result::Result<()> {
    let channel = SearchChannel::start("localhost:1491", "SecretPassword")?;
    let objects = channel.query("collection", "bucket", "recipe")?;
    dbg!(objects);

    Ok(())
}

Ingest channel

Note: This example requires enabling the ingest feature.

use sonic_channel::*;

fn main() -> result::Result<()> {
    let channel = IngestChannel::start("localhost:1491", "SecretPassword")?;
    let pushed = channel.push("collection", "bucket", "object:1", "my best recipe")?;
    // or
    // let pushed = channel.push_with_locale("collection", "bucket", "object:1", "Мой лучший рецепт", "rus")?;
    dbg!(pushed);

    Ok(())
}

Control channel

Note: This example requires enabling the control feature.

use sonic_channel::*;

fn main() -> result::Result<()> {
    let channel = ControlChannel::start("localhost:1491", "SecretPassword")?;
    let result = channel.consolidate()?;
    assert_eq!(result, true);

    Ok(())
}

Available features

  • default - ["search"]
  • search - Add sonic search mode with methods
  • ingest - Add sonic ingest mode with methods
  • control - Add sonic control mode with methods