Skip to main content

Query

Struct Query 

Source
#[non_exhaustive]
pub struct Query { /* private fields */ }
Expand description

A search query.

Implementations§

Source§

impl Query

Source

pub fn semantic(text: impl Into<String>) -> Self

Pure semantic search.

Source

pub fn text(text: impl Into<String>) -> Self

Pure lexical search.

Source

pub fn hybrid(text: impl Into<String>) -> Self

Hybrid (RRF) search; default alpha = 0.6.

Source

pub fn hierarchical(self) -> Self

Plan 10: opt into hierarchical descent. The search starts at the configured scope (or the tenant root if unset) and descends through internal nodes, scoring child summaries at each level and pruning branches whose top scores fall below Query::prune_threshold. Leaves are searched only after the parent’s index has identified them as relevant. Defaults to flat (whole-tree) search when off.

Source

pub fn prune_threshold(self, t: f32) -> Self

Plan 10: prune children whose mid-level summary score is below t. Default is no pruning — every child whose score made the top-K of the parent’s index is descended into. Clamped to [-1, 1] (cosine range).

Source

pub fn descend_factor(self, n: u32) -> Self

Plan 10: at each internal level, descend into the top k * descend_factor children. Higher = wider beam = slower but more recall; lower = narrower beam = faster but more risk of pruning the right answer. Default 4. Clamped to >= 1.

Source

pub fn is_hierarchical(&self) -> bool

Whether this query is in hierarchical mode.

Source

pub fn alpha(self, alpha: f32) -> Self

Override hybrid alpha. No effect on non-hybrid queries.

Source

pub fn within(self, path: PartitionPath) -> Self

Restrict the search to a partition (and its descendants).

Source

pub fn with_embedding(self, vector: Vec<f32>) -> Self

Caller hands the engine a pre-computed query vector. Used by caller-owned-models pathways (Apple Foundation Models, OpenAI proxies, Swift FFI consumers) where the model runs outside the library on the query side.

When set, the engine bypasses its Embedder (if any) for the query step. The vector’s length must match schema_meta.embedder_dims; mismatch surfaces from the underlying vector index. Has no effect on QueryMode::Text (lexical search ignores the vector).

See spec § 12 (caller-owned models) and § 12.13.

Source

pub fn precomputed_embedding(&self) -> Option<&[f32]>

Borrow the precomputed query vector, if any. None means the engine must invoke its configured Embedder to derive the query vector.

Source

pub fn text_str(&self) -> &str

Borrow the query text.

Source

pub fn mode(&self) -> &QueryMode

Borrow the mode.

Source

pub fn scope(&self) -> Option<&PartitionPath>

Borrow the partition restriction (if any).

Trait Implementations§

Source§

impl Clone for Query

Source§

fn clone(&self) -> Query

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Query

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Query

§

impl RefUnwindSafe for Query

§

impl Send for Query

§

impl Sync for Query

§

impl Unpin for Query

§

impl UnsafeUnpin for Query

§

impl UnwindSafe for Query

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more