Yurii Sokolovskyi 8708b8e54b Initial commit | 5 ay önce | |
---|---|---|
.. | ||
.github | 5 ay önce | |
src | 5 ay önce | |
tests | 5 ay önce | |
.gitignore | 5 ay önce | |
CODE_OF_CONDUCT.md | 5 ay önce | |
Cargo.lock | 5 ay önce | |
Cargo.toml | 5 ay önce | |
LICENSE | 5 ay önce | |
README.md | 5 ay önce | |
docker-compose.test.yml | 5 ay önce | |
flake.lock | 5 ay önce | |
flake.nix | 5 ay önce | |
sonic.cfg | 5 ay önce |
Rust client for sonic search backend.
We recommend you start with the documentation.
The MSRV is: 1.58.1
Add sonic-channel = { version = "1.1" }
as a dependency in Cargo.toml
.
Cargo.toml
example:
[package]
name = "my-crate"
version = "0.1.0"
authors = ["Me <[email protected]>"]
[dependencies]
sonic-channel = { version = "1.1", features = ["ingest"] }
Add default-features = false
to dependency, if you want to exclude default
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(QueryRequest::new(
Dest::col_buc("collection", "bucket"),
"recipe",
))?;
dbg!(objects);
Ok(())
}
Note: This example requires enabling the ingest
feature.
use sonic_channel::*;
fn main() -> result::Result<()> {
let channel = IngestChannel::start(
"localhost:1491",
"SecretPassword",
)?;
let dest = Dest::col_buc("collection", "bucket").obj("object:1");
let pushed = channel.push(PushRequest::new(dest, "my best recipe"))?;
// or
// let pushed = channel.push(
// PushRequest::new(dest, "Мой лучший рецепт").lang(Lang::Rus)
// )?;
dbg!(pushed);
Ok(())
}
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, ());
Ok(())
}