[][src]Struct sonic_channel::SonicChannel

pub struct SonicChannel { /* fields omitted */ }

Root and Heart of this library.

You can connect to the sonic search backend and run all supported protocol methods.

Implementations

impl SonicChannel[src]

pub fn connect_with_start<A, S>(
    mode: ChannelMode,
    addr: A,
    password: S
) -> Result<Self> where
    A: ToSocketAddrs,
    S: ToString
[src]

Connect to the search backend in chosen mode.

I think we shouldn't separate commands connect and start because we haven't possibility to change channel in sonic server, if we already chosen one of them. 🤔

use sonic_channel::*;

fn main() -> result::Result<()> {
    let channel = SonicChannel::connect_with_start(
        ChannelMode::Search,
        "localhost:1491",
        "SecretPassword"
    )?;

    // Now you can use all method of Search channel.
    let objects = channel.query("search", "default", "beef");
     
    Ok(())
}

pub fn quit(&self) -> Result<<QuitCommand as StreamCommand>::Response>[src]

Stop connection.

let channel = SonicChannel::connect_with_start(
    ChannelMode::Search,
    "localhost:1491",
    "SecretPassword",
)?;

channel.quit()?;
        

pub fn ping(&self) -> Result<<PingCommand as StreamCommand>::Response>[src]

Ping server.

let channel = SonicChannel::connect_with_start(
    ChannelMode::Search,
    "localhost:1491",
    "SecretPassword",
)?;

channel.ping()?;
        

pub fn push<'a>(
    &self,
    collection: &'a str,
    bucket: &'a str,
    object: &'a str,
    text: &'a str
) -> Result<<PushCommand as StreamCommand>::Response>
[src]

Push search data in the index.

Note: This method requires enabling the ingest feature and start connection in Ingest mode.

let ingest_channel = SonicChannel::connect_with_start(
    ChannelMode::Ingest,
    "localhost:1491",
    "SecretPassword",
)?;

let result = ingest_channel.push(
    "search",
    "default",
    "recipe:295",
    "Sweet Teriyaki Beef Skewers",
)?;
assert_eq!(result, true);

pub fn push_with_locale<'a>(
    &self,
    collection: &'a str,
    bucket: &'a str,
    object: &'a str,
    text: &'a str,
    locale: &'a str
) -> Result<<PushCommand as StreamCommand>::Response>
[src]

Push search data in the index with locale parameter in ISO 639-3 code.

Note: This method requires enabling the ingest feature and start connection in Ingest mode.

let ingest_channel = SonicChannel::connect_with_start(
    ChannelMode::Ingest,
    "localhost:1491",
    "SecretPassword",
)?;

let result = ingest_channel.push_with_locale(
    "search",
    "default",
    "recipe:296",
    "Гренки с жареным картофелем и сыром",
    "rus",
)?;
assert_eq!(result, true);

pub fn pop<'a>(
    &self,
    collection: &'a str,
    bucket: &'a str,
    object: &'a str,
    text: &'a str
) -> Result<<PopCommand as StreamCommand>::Response>
[src]

Pop search data from the index. Returns removed words count as usize type.

Note: This method requires enabling the ingest feature and start connection in Ingest mode.

let ingest_channel = SonicChannel::connect_with_start(
    ChannelMode::Ingest,
    "localhost:1491",
    "SecretPassword",
)?;

let result = ingest_channel.pop("search", "default", "recipe:295", "beef")?;
assert_eq!(result, 1);

pub fn flushc<'a>(
    &self,
    collection: &'a str
) -> Result<<FlushCommand as StreamCommand>::Response>
[src]

Flush all indexed data from collections.

Note: This method requires enabling the ingest feature and start connection in Ingest mode.

let ingest_channel = SonicChannel::connect_with_start(
    ChannelMode::Ingest,
    "localhost:1491",
    "SecretPassword",
)?;

let flushc_count = ingest_channel.flushc("search")?;
dbg!(flushc_count);

pub fn flushb<'a>(
    &self,
    collection: &'a str,
    bucket: &'a str
) -> Result<<FlushCommand as StreamCommand>::Response>
[src]

Flush all indexed data from bucket in a collection.

Note: This method requires enabling the ingest feature and start connection in Ingest mode.

let ingest_channel = SonicChannel::connect_with_start(
    ChannelMode::Ingest,
    "localhost:1491",
    "SecretPassword",
)?;

let flushb_count = ingest_channel.flushb("search", "default")?;
dbg!(flushb_count);

pub fn flusho<'a>(
    &self,
    collection: &'a str,
    bucket: &'a str,
    object: &'a str
) -> Result<<FlushCommand as StreamCommand>::Response>
[src]

Flush all indexed data from an object in a bucket in collection.

Note: This method requires enabling the ingest feature and start connection in Ingest mode.

let ingest_channel = SonicChannel::connect_with_start(
    ChannelMode::Ingest,
    "localhost:1491",
    "SecretPassword",
)?;

let flusho_count = ingest_channel.flusho("search", "default", "recipe:296")?;
dbg!(flusho_count);

pub fn bucket_count<'a>(
    &self,
    collection: &'a str
) -> Result<<CountCommand as StreamCommand>::Response>
[src]

Bucket count in indexed search data of your collection.

Note: This method requires enabling the ingest feature and start connection in Ingest mode.

let ingest_channel = SonicChannel::connect_with_start(
    ChannelMode::Ingest,
    "localhost:1491",
    "SecretPassword",
)?;

let bucket_count = ingest_channel.bucket_count("search")?;
dbg!(bucket_count);

pub fn object_count<'a>(
    &self,
    collection: &'a str,
    bucket: &'a str
) -> Result<<CountCommand as StreamCommand>::Response>
[src]

Object count of bucket in indexed search data.

Note: This method requires enabling the ingest feature and start connection in Ingest mode.

let ingest_channel = SonicChannel::connect_with_start(
    ChannelMode::Ingest,
    "localhost:1491",
    "SecretPassword",
)?;

let object_count = ingest_channel.object_count("search", "default")?;
dbg!(object_count);

pub fn word_count<'a>(
    &self,
    collection: &'a str,
    bucket: &'a str,
    object: &'a str
) -> Result<<CountCommand as StreamCommand>::Response>
[src]

Object word count in indexed bucket search data.

Note: This method requires enabling the ingest feature and start connection in Ingest mode.

let ingest_channel = SonicChannel::connect_with_start(
    ChannelMode::Ingest,
    "localhost:1491",
    "SecretPassword",
)?;

let word_count = ingest_channel.word_count("search", "default", "recipe:296")?;
dbg!(word_count);

pub fn query<'a>(
    &self,
    collection: &'a str,
    bucket: &'a str,
    terms: &'a str
) -> Result<<QueryCommand as StreamCommand>::Response>
[src]

Query objects in database.

Note: This method requires enabling the search feature and start connection in Search mode.

let search_channel = SonicChannel::connect_with_start(
    ChannelMode::Search,
    "localhost:1491",
    "SecretPassword",
)?;

let result = search_channel.query("search", "default", "Beef")?;
dbg!(result);

pub fn query_with_limit<'a>(
    &self,
    collection: &'a str,
    bucket: &'a str,
    terms: &'a str,
    limit: usize
) -> Result<<QueryCommand as StreamCommand>::Response>
[src]

Query limited objects in database. This method similar query but you can configure limit of result.

Note: This method requires enabling the search feature and start connection in Search mode.

let search_channel = SonicChannel::connect_with_start(
    ChannelMode::Search,
    "localhost:1491",
    "SecretPassword",
)?;

let result = search_channel.query_with_limit(
    "search",
    "default",
    "Beef",
    10,
)?;
dbg!(result);

pub fn query_with_limit_and_offset<'a>(
    &self,
    collection: &'a str,
    bucket: &'a str,
    terms: &'a str,
    limit: usize,
    offset: usize
) -> Result<<QueryCommand as StreamCommand>::Response>
[src]

Query limited objects in database. This method similar query_with_limit but you can put offset in your query.

Note: This method requires enabling the search feature and start connection in Search mode.

let search_channel = SonicChannel::connect_with_start(
    ChannelMode::Search,
    "localhost:1491",
    "SecretPassword",
)?;

let result = search_channel.query_with_limit_and_offset(
    "search",
    "default",
    "Beef",
    10,
    10,
)?;
dbg!(result);

pub fn suggest<'a>(
    &self,
    collection: &'a str,
    bucket: &'a str,
    word: &'a str
) -> Result<<SuggestCommand as StreamCommand>::Response>
[src]

Suggest auto-completes words.

Note: This method requires enabling the search feature and start connection in Search mode.

let search_channel = SonicChannel::connect_with_start(
    ChannelMode::Search,
    "localhost:1491",
    "SecretPassword",
)?;

let result = search_channel.suggest("search", "default", "Beef")?;
dbg!(result);

pub fn suggest_with_limit<'a>(
    &self,
    collection: &'a str,
    bucket: &'a str,
    word: &'a str,
    limit: usize
) -> Result<<SuggestCommand as StreamCommand>::Response>
[src]

Suggest auto-completes words with limit.

Note: This method requires enabling the search feature and start connection in Search mode.

let search_channel = SonicChannel::connect_with_start(
    ChannelMode::Search,
    "localhost:1491",
    "SecretPassword",
)?;

let result = search_channel.suggest_with_limit("search", "default", "Beef", 5)?;
dbg!(result);

pub fn consolidate(&self) -> Result<<TriggerCommand as StreamCommand>::Response>[src]

Consolidate indexed search data instead of waiting for the next automated consolidation tick.

Note: This method requires enabling the control feature and start connection in Control mode.

let control_channel = SonicChannel::connect_with_start(
    ChannelMode::Control,
    "localhost:1491",
    "SecretPassword",
)?;

let result = control_channel.consolidate()?;
assert_eq!(result, true);

pub fn backup<'a>(
    &self,
    action: &'a str
) -> Result<<TriggerCommand as StreamCommand>::Response>
[src]

Backup KV + FST to /<BACKUP_{KV/FST}_PATH> See sonic backend source code for more information.

Note: This method requires enabling the control feature and start connection in Control mode.

let control_channel = SonicChannel::connect_with_start(
    ChannelMode::Control,
    "localhost:1491",
    "SecretPassword",
)?;

let result = control_channel.backup("2020-08-07T23-48")?;
assert_eq!(result, true);

pub fn restore<'a>(
    &self,
    action: &'a str
) -> Result<<TriggerCommand as StreamCommand>::Response>
[src]

Restore KV + FST from if you already have backup with the same name.

Note: This method requires enabling the control feature and start connection in Control mode.

let control_channel = SonicChannel::connect_with_start(
    ChannelMode::Control,
    "localhost:1491",
    "SecretPassword",
)?;

let result = control_channel.restore("2020-08-07T23-48")?;
assert_eq!(result, true);

Trait Implementations

impl Debug for SonicChannel[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.