pub struct PostgresSearchStore { /* private fields */ }Expand description
Postgres-backed search storage.
Implements both SearchBackend (the index) and DocumentSource
(reading records back out of their own tables), because both need the same
connection pool and the same identifier-safety rules. SearchPlugin::postgres()
installs one instance as both.
The pool is installed at startup (PostgresSearchStore::install_pool),
so the store can be constructed by the plugin builder before an AppState
exists.
Implementations§
Source§impl PostgresSearchStore
impl PostgresSearchStore
Sourcepub fn install_pool(&self, pool: Pool<RuntimeConnection>)
pub fn install_pool(&self, pool: Pool<RuntimeConnection>)
Install the application’s connection pool. Idempotent; the first call wins.
Sourcepub fn vector_mode(&self) -> Option<VectorMode>
pub fn vector_mode(&self) -> Option<VectorMode>
The resolved vector storage mode, once ensure_index has run.
Sourcepub fn vector_column_width(&self) -> Option<usize>
pub fn vector_column_width(&self) -> Option<usize>
Declared width of the physical embedding_vec column, if it exists.
Independent of Self::vector_mode: the column can outlive the mode
that created it.
Trait Implementations§
Source§impl Debug for PostgresSearchStore
impl Debug for PostgresSearchStore
Source§impl DocumentSource for PostgresSearchStore
impl DocumentSource for PostgresSearchStore
Source§fn fetch<'a>(
&'a self,
definition: &'a IndexDefinition,
ids: &'a [i64],
) -> BoxFuture<'a, SearchResult<Vec<SearchDocument>>>
fn fetch<'a>( &'a self, definition: &'a IndexDefinition, ids: &'a [i64], ) -> BoxFuture<'a, SearchResult<Vec<SearchDocument>>>
Fetch the documents for
ids. Read moreSource§fn scan<'a>(
&'a self,
definition: &'a IndexDefinition,
after: Option<i64>,
limit: usize,
) -> BoxFuture<'a, SearchResult<Vec<SearchDocument>>>
fn scan<'a>( &'a self, definition: &'a IndexDefinition, after: Option<i64>, limit: usize, ) -> BoxFuture<'a, SearchResult<Vec<SearchDocument>>>
Source§impl SearchBackend for PostgresSearchStore
impl SearchBackend for PostgresSearchStore
Source§fn capabilities(&self) -> BackendCapabilities
fn capabilities(&self) -> BackendCapabilities
What this backend supports.
Source§fn write_watermark(&self) -> BoxFuture<'_, SearchResult<Option<String>>>
fn write_watermark(&self) -> BoxFuture<'_, SearchResult<Option<String>>>
A marker for “now” on the backend’s own clock, for
index_unless_newer. Read moreSource§fn index_unless_newer<'a>(
&'a self,
definition: &'a IndexDefinition,
documents: &'a [IndexedDocument],
watermark: Option<&'a str>,
) -> BoxFuture<'a, SearchResult<()>>
fn index_unless_newer<'a>( &'a self, definition: &'a IndexDefinition, documents: &'a [IndexedDocument], watermark: Option<&'a str>, ) -> BoxFuture<'a, SearchResult<()>>
Source§fn ensure_index<'a>(
&'a self,
definition: &'a IndexDefinition,
) -> BoxFuture<'a, SearchResult<()>>
fn ensure_index<'a>( &'a self, definition: &'a IndexDefinition, ) -> BoxFuture<'a, SearchResult<()>>
Create or migrate the storage for
definition. Must be idempotent —
it runs on every boot — and must reject a definition that fails
IndexDefinition::validate.Source§fn index<'a>(
&'a self,
definition: &'a IndexDefinition,
documents: &'a [IndexedDocument],
) -> BoxFuture<'a, SearchResult<()>>
fn index<'a>( &'a self, definition: &'a IndexDefinition, documents: &'a [IndexedDocument], ) -> BoxFuture<'a, SearchResult<()>>
Upsert
documents, keyed by (index, id). Must be idempotent: the
reindex job delivers at least once.Source§fn delete<'a>(
&'a self,
definition: &'a IndexDefinition,
ids: &'a [i64],
) -> BoxFuture<'a, SearchResult<()>>
fn delete<'a>( &'a self, definition: &'a IndexDefinition, ids: &'a [i64], ) -> BoxFuture<'a, SearchResult<()>>
Remove documents by record id. Removing an absent id is a no-op, not an
error — deletes are replayed.
Source§fn clear<'a>(
&'a self,
definition: &'a IndexDefinition,
) -> BoxFuture<'a, SearchResult<()>>
fn clear<'a>( &'a self, definition: &'a IndexDefinition, ) -> BoxFuture<'a, SearchResult<()>>
Remove every document in the index.
Source§fn keyword_search<'a>(
&'a self,
definition: &'a IndexDefinition,
query: &'a KeywordQuery,
) -> BoxFuture<'a, SearchResult<Page<SearchHit>>>
fn keyword_search<'a>( &'a self, definition: &'a IndexDefinition, query: &'a KeywordQuery, ) -> BoxFuture<'a, SearchResult<Page<SearchHit>>>
Ranked, paginated keyword search. See
KeywordQuery for the query
semantics every backend must implement.Source§fn vector_search<'a>(
&'a self,
definition: &'a IndexDefinition,
query: &'a VectorQuery,
) -> BoxFuture<'a, SearchResult<Vec<SearchHit>>>
fn vector_search<'a>( &'a self, definition: &'a IndexDefinition, query: &'a VectorQuery, ) -> BoxFuture<'a, SearchResult<Vec<SearchHit>>>
k-NN search over the embedded field.
Source§fn embedding<'a>(
&'a self,
definition: &'a IndexDefinition,
id: i64,
filter: &'a SearchFilter,
) -> BoxFuture<'a, SearchResult<Option<Vec<f32>>>>
fn embedding<'a>( &'a self, definition: &'a IndexDefinition, id: i64, filter: &'a SearchFilter, ) -> BoxFuture<'a, SearchResult<Option<Vec<f32>>>>
Read back the stored embedding for one record, so “find records like
this one” needs no re-embedding. Read more
Auto Trait Implementations§
impl !Freeze for PostgresSearchStore
impl !RefUnwindSafe for PostgresSearchStore
impl !UnwindSafe for PostgresSearchStore
impl Send for PostgresSearchStore
impl Sync for PostgresSearchStore
impl Unpin for PostgresSearchStore
impl UnsafeUnpin for PostgresSearchStore
Blanket Implementations§
Source§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> Self::Output
fn aggregate_filter<P>(self, f: P) -> Self::Output
Add an aggregate function filter Read more
Source§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
Add an aggregate function order Read more
Source§impl<T> AutumnCounterCaches for Twhere
T: 'static,
impl<T> AutumnCounterCaches for Twhere
T: 'static,
Source§const HAS_COUNTER_CACHES: bool = false
const HAS_COUNTER_CACHES: bool = false
Whether this model has any counter cache at all. Read more
Source§fn counter_caches() -> &'static [CounterCacheSpec<Self>]
fn counter_caches() -> &'static [CounterCacheSpec<Self>]
The model’s counter-cache specs, in declaration order.
Source§impl<T> AutumnDependents for Twhere
T: ?Sized,
impl<T> AutumnDependents for Twhere
T: ?Sized,
Source§fn dependents() -> &'static [RuntimeDependentSpec]
fn dependents() -> &'static [RuntimeDependentSpec]
The model’s dependent-cascade specs, in declaration order. Defaults to
none;
#[model] overrides via an inherent shadow when dependents exist.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
Convert
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
Convert
&self to an expression for Diesel’s query builder. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T, Conn> RunQueryDsl<Conn> for T
impl<T, Conn> RunQueryDsl<Conn> for T
Source§fn execute<'conn, 'query>(
self,
conn: &'conn mut Conn,
) -> <Conn as AsyncConnectionCore>::ExecuteFuture<'conn, 'query>
fn execute<'conn, 'query>( self, conn: &'conn mut Conn, ) -> <Conn as AsyncConnectionCore>::ExecuteFuture<'conn, 'query>
Executes the given command, returning the number of rows affected. Read more
Source§fn load<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
fn load<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
Source§fn load_stream<'conn, 'query, U>(
self,
conn: &'conn mut Conn,
) -> Self::LoadFuture<'conn>where
Conn: AsyncConnectionCore,
U: 'conn,
Self: LoadQuery<'query, Conn, U> + 'query,
fn load_stream<'conn, 'query, U>(
self,
conn: &'conn mut Conn,
) -> Self::LoadFuture<'conn>where
Conn: AsyncConnectionCore,
U: 'conn,
Self: LoadQuery<'query, Conn, U> + 'query,
Executes the given query, returning a [
Stream] with the returned rows. Read moreSource§fn get_result<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, LoadNext<Pin<Box<Self::Stream<'conn>>>>>
fn get_result<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, LoadNext<Pin<Box<Self::Stream<'conn>>>>>
Runs the command, and returns the affected row. Read more
Source§fn get_results<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
fn get_results<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
Runs the command, returning an
Vec with the affected rows. Read moreSource§impl<T> Scoped for T
impl<T> Scoped for T
Source§fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
Open a deferred
ScopeQuery for this type. Resolves the
registered scope at .load() time, not here.Source§impl<T> WindowExpressionMethods for T
impl<T> WindowExpressionMethods for T
Source§fn over(self) -> Self::Outputwhere
Self: OverDsl,
fn over(self) -> Self::Outputwhere
Self: OverDsl,
Turn a function call into a window function call Read more
Source§fn window_filter<P>(self, f: P) -> Self::Output
fn window_filter<P>(self, f: P) -> Self::Output
Add a filter to the current window function Read more
Source§fn partition_by<E>(self, expr: E) -> Self::Outputwhere
Self: PartitionByDsl<E>,
fn partition_by<E>(self, expr: E) -> Self::Outputwhere
Self: PartitionByDsl<E>,
Add a partition clause to the current window function Read more
Source§fn window_order<E>(self, expr: E) -> Self::Outputwhere
Self: OrderWindowDsl<E>,
fn window_order<E>(self, expr: E) -> Self::Outputwhere
Self: OrderWindowDsl<E>,
Add a order clause to the current window function Read more