pub struct Query {
pub text: String,
pub entities: Vec<String>,
pub kinds: Vec<MemoryKind>,
pub boost_only: Vec<String>,
pub limit: usize,
}Expand description
What a search is looking for.
Fields§
§text: StringRaw query text; tokenized on execution.
entities: Vec<String>Entity surface forms that should receive an exact-match boost.
kinds: Vec<MemoryKind>Restrict to these kinds; empty means any.
boost_only: Vec<String>Terms that may rank a hit but never admit one.
A memory lookup is nearly always phrased about its owner — “what’s my usual coffee”, or, when a model writes the query, “the user’s usual coffee”. Those words are the corpus’s own subject form and its aliases, so they have a posting in almost every record. Treated as ordinary terms they cost two things at once: precision, because a question the corpus cannot answer still matches everything and comes back with five arbitrary facts; and time, because every query then walks the whole corpus and sorts it. Measured, that was a recall going from 1 ms at 250 records to 118 ms at 16,000 — superlinear, and eight times past the engine’s own 15 ms lexical deadline.
Listing them here keeps what they are good for and drops what they are not. They still contribute their score to a record some topical term already matched, which is what lets “what coating do I have” prefer the owner’s record over forty belonging to other people. They no longer put a record into the running on their own.
limit: usizeMaximum hits to return.
Implementations§
Source§impl Query
impl Query
Sourcepub fn with_entities<I, S>(self, entities: I) -> Self
pub fn with_entities<I, S>(self, entities: I) -> Self
Boost documents whose subject or entities match these surface forms.
Sourcepub fn with_kinds(self, kinds: Vec<MemoryKind>) -> Self
pub fn with_kinds(self, kinds: Vec<MemoryKind>) -> Self
Restrict the search to certain memory kinds.
Sourcepub fn with_boost_only<I, S>(self, terms: I) -> Self
pub fn with_boost_only<I, S>(self, terms: I) -> Self
Mark terms that may rank a hit but never admit one.
Sourcepub fn with_limit(self, limit: usize) -> Self
pub fn with_limit(self, limit: usize) -> Self
Cap the result count.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Query
impl RefUnwindSafe for Query
impl Send for Query
impl Sync for Query
impl Unpin for Query
impl UnwindSafe for Query
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].