Skip to main content

SearchBackend

Trait SearchBackend 

Source
pub trait SearchBackend:
    Send
    + Sync
    + 'static {
    // Required methods
    fn search<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        tenant_slug: &'life1 str,
        query: &'life2 str,
        limit: i64,
    ) -> Pin<Box<dyn Future<Output = Vec<i64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn index<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        tenant_slug: &'life1 str,
        doc: &'life2 SearchDoc,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        tenant_slug: &'life1 str,
        page_id: i64,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

An external full-text backend (Elasticsearch, …). When one is installed via set_backend, it takes priority over the built-in Postgres path: search goes to the backend, and pages are indexed / removed through it. Object-safe so it can live behind Arc<dyn …>.

Required Methods§

Source

fn search<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, tenant_slug: &'life1 str, query: &'life2 str, limit: i64, ) -> Pin<Box<dyn Future<Output = Vec<i64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Page ids matching query for tenant_slug, ranked best-first.

Source

fn index<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, tenant_slug: &'life1 str, doc: &'life2 SearchDoc, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Upsert one page document.

Source

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, tenant_slug: &'life1 str, page_id: i64, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove a page document (on unpublish / delete).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§