Skip to main content

AsyncRetriever

Trait AsyncRetriever 

Source
pub trait AsyncRetriever: Send + Sync {
    type Query: Send + Sync;
    type Result: Send + Sync;
    type Error: Error + Send + Sync + 'static;

    // Required methods
    fn search<'life0, 'async_trait>(
        &'life0 self,
        query: Self::Query,
        k: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Self::Result>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn search_with_context<'life0, 'life1, 'async_trait>(
        &'life0 self,
        query: Self::Query,
        context: &'life1 str,
        k: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Self::Result>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn update<'life0, 'async_trait>(
        &'life0 mut self,
        content: Vec<String>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn search_batch<'life0, 'async_trait>(
        &'life0 self,
        queries: Vec<Self::Query>,
        k: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<Self::Result>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn update_batch<'life0, 'async_trait>(
        &'life0 mut self,
        content_batches: Vec<Vec<String>>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn refresh_index<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn health_check<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn get_stats<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<RetrievalStats>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Async text retrieval abstraction for non-blocking content retrieval

§Async Version

This trait provides async operations for content retrieval with better scalability and concurrency.

Required Associated Types§

Source

type Query: Send + Sync

The query type this retriever accepts

Source

type Result: Send + Sync

The result type this retriever returns

Source

type Error: Error + Send + Sync + 'static

The error type returned by retrieval operations

Required Methods§

Source

fn search<'life0, 'async_trait>( &'life0 self, query: Self::Query, k: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Self::Result>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Perform a search query

Source

fn search_with_context<'life0, 'life1, 'async_trait>( &'life0 self, query: Self::Query, context: &'life1 str, k: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Self::Result>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Perform a search with additional context

Source

fn update<'life0, 'async_trait>( &'life0 mut self, content: Vec<String>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Update the retriever with new content

Provided Methods§

Source

fn search_batch<'life0, 'async_trait>( &'life0 self, queries: Vec<Self::Query>, k: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<Self::Result>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Perform multiple search queries concurrently

Source

fn update_batch<'life0, 'async_trait>( &'life0 mut self, content_batches: Vec<Vec<String>>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Update the retriever with new content in batches

Source

fn refresh_index<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Refresh/rebuild the retrieval index

Source

fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Health check for retrieval system

Source

fn get_stats<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<RetrievalStats>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get retrieval statistics

Implementors§