Skip to main content

QueryNode

Enum QueryNode 

Source
pub enum QueryNode {
    Vector {
        embedding: Vec<f32>,
        top_k: usize,
        min_score: Option<DeterministicScore>,
    },
    Keyword {
        text: String,
        top_k: usize,
        min_score: Option<DeterministicScore>,
    },
    Fuse {
        children: Vec<QueryNode>,
        strategy: FuseStrategy,
        top_k: usize,
    },
    Filter {
        child: Box<QueryNode>,
        predicate: FilterPredicate,
    },
    Rerank {
        child: Box<QueryNode>,
        method: RerankMethod,
        top_k: usize,
    },
    Empty,
}
Expand description

A node in the Query IR tree.

Each variant represents a single retrieval operation or combinator. Nodes compose recursively – a Fuse holds children, a Filter wraps a single child, and leaf nodes (Vector, Keyword, Empty) terminate the tree.

Variants§

§

Vector

Vector similarity search (e.g. HNSW nearest-neighbor).

Fields

§embedding: Vec<f32>

Pre-computed query embedding.

§top_k: usize

Number of results to return.

§min_score: Option<DeterministicScore>

Optional minimum similarity threshold.

§

Keyword

Keyword / BM25 text search.

Fields

§text: String

Query text.

§top_k: usize

Number of results to return.

§min_score: Option<DeterministicScore>

Optional minimum relevance threshold.

§

Fuse

Fuse multiple sub-queries into a single ranked list.

Fields

§children: Vec<QueryNode>

Sub-queries to fuse.

§strategy: FuseStrategy

Strategy for combining ranked lists.

§top_k: usize

Number of results after fusion.

§

Filter

Filter the results of a sub-query.

Fields

§child: Box<QueryNode>

The sub-query whose results are filtered.

§predicate: FilterPredicate

Predicate to apply.

§

Rerank

Rerank the results of a sub-query.

Fields

§child: Box<QueryNode>

The sub-query whose results are reranked.

§method: RerankMethod

Reranking method.

§top_k: usize

Number of results after reranking.

§

Empty

An empty query that is guaranteed to produce no results.

Useful as the result of constant-folding provably-empty sub-trees.

Implementations§

Source§

impl QueryNode

Source

pub fn vector(embedding: Vec<f32>, top_k: usize) -> Self

Create a vector search leaf node.

Source

pub fn keyword(text: impl Into<String>, top_k: usize) -> Self

Create a keyword search leaf node.

Source

pub fn hybrid( embedding: Vec<f32>, text: impl Into<String>, top_k: usize, ) -> Self

Create a hybrid query (vector + keyword with RRF fusion, top_k * 3 candidates each).

Source

pub fn with_min_score(self, min_score: DeterministicScore) -> Self

Wrap this node with a minimum-score filter.

Source

pub fn with_top_k(self, k: usize) -> Self

Wrap this node with a top-k truncation filter.

Source

pub fn is_empty(&self) -> bool

Returns true if this query is provably empty (no results possible).

A query is provably empty when:

  • It is the Empty variant.
  • A leaf has top_k == 0.
  • A keyword leaf has empty text.
  • A fuse node has no children.
  • A filter/rerank wraps a provably-empty child.
Source

pub fn leaf_count(&self) -> usize

Count the total number of leaf search operations in the tree.

Vector and Keyword nodes each count as 1. Empty counts as 0. Combinators recurse into their children.

Source

pub fn top_k(&self) -> usize

Return the effective top_k requested by this node.

For Filter nodes with a TopK predicate, the predicate’s value is returned. Otherwise the child’s top_k propagates upward.

Source

pub fn depth(&self) -> usize

Return the depth of the IR tree (longest root-to-leaf path).

Leaf nodes have depth 1. Empty has depth 0.

Trait Implementations§

Source§

impl Clone for QueryNode

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for QueryNode

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for QueryNode

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for QueryNode

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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<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