Skip to main content

QueryBuilder

Struct QueryBuilder 

Source
pub struct QueryBuilder { /* private fields */ }
Expand description

Fluent builder for constructing a QueryAst.

Start with QueryBuilder::nodes and chain filtering, traversal, and expansion steps before calling compile or compile_grouped.

Implementations§

Source§

impl QueryBuilder

Source

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

Create a builder that queries nodes of the given kind.

Add a vector similarity search step.

Add a full-text search step.

The input is parsed into FathomDB’s safe supported subset: literal terms, quoted phrases, uppercase OR, uppercase NOT, and implicit AND by adjacency. Unsupported syntax remains literal rather than being passed through as raw FTS5 control syntax.

Source

pub fn traverse( self, direction: TraverseDirection, label: impl Into<String>, max_depth: usize, ) -> Self

Add a graph traversal step following edges of the given label.

Source

pub fn filter_logical_id_eq(self, logical_id: impl Into<String>) -> Self

Filter results to a single logical ID.

Source

pub fn filter_kind_eq(self, kind: impl Into<String>) -> Self

Filter results to nodes matching the given kind.

Source

pub fn filter_source_ref_eq(self, source_ref: impl Into<String>) -> Self

Filter results to nodes matching the given source_ref.

Source

pub fn filter_content_ref_not_null(self) -> Self

Filter results to nodes where content_ref is not NULL.

Source

pub fn filter_content_ref_eq(self, content_ref: impl Into<String>) -> Self

Filter results to nodes matching the given content_ref URI.

Source

pub fn filter_json_text_eq( self, path: impl Into<String>, value: impl Into<String>, ) -> Self

Filter results where a JSON property at path equals the given text value.

Source

pub fn filter_json_bool_eq(self, path: impl Into<String>, value: bool) -> Self

Filter results where a JSON property at path equals the given boolean value.

Source

pub fn filter_json_integer_gt(self, path: impl Into<String>, value: i64) -> Self

Filter results where a JSON integer at path is greater than value.

Source

pub fn filter_json_integer_gte( self, path: impl Into<String>, value: i64, ) -> Self

Filter results where a JSON integer at path is greater than or equal to value.

Source

pub fn filter_json_integer_lt(self, path: impl Into<String>, value: i64) -> Self

Filter results where a JSON integer at path is less than value.

Source

pub fn filter_json_integer_lte( self, path: impl Into<String>, value: i64, ) -> Self

Filter results where a JSON integer at path is less than or equal to value.

Source

pub fn filter_json_timestamp_gt( self, path: impl Into<String>, value: i64, ) -> Self

Filter results where a JSON timestamp at path is after value (epoch seconds).

Source

pub fn filter_json_timestamp_gte( self, path: impl Into<String>, value: i64, ) -> Self

Filter results where a JSON timestamp at path is at or after value.

Source

pub fn filter_json_timestamp_lt( self, path: impl Into<String>, value: i64, ) -> Self

Filter results where a JSON timestamp at path is before value.

Source

pub fn filter_json_timestamp_lte( self, path: impl Into<String>, value: i64, ) -> Self

Filter results where a JSON timestamp at path is at or before value.

Source

pub fn filter_json_fused_text_eq_unchecked( self, path: impl Into<String>, value: impl Into<String>, ) -> Self

Append a fused JSON text-equality predicate without validating whether the caller has a property-FTS schema for the kind.

Callers must have already validated the fusion gate; the tethered crate::QueryBuilder has no engine handle to consult a schema. Mis-use — calling this without prior schema validation — produces SQL that pushes a json_extract predicate into the search CTE’s inner WHERE clause. That is valid SQL but defeats the “developer opt-in” contract.

Source

pub fn filter_json_fused_timestamp_gt_unchecked( self, path: impl Into<String>, value: i64, ) -> Self

Append a fused JSON timestamp-greater-than predicate without validating the fusion gate. See Self::filter_json_fused_text_eq_unchecked for the contract.

Source

pub fn filter_json_fused_timestamp_gte_unchecked( self, path: impl Into<String>, value: i64, ) -> Self

Append a fused JSON timestamp-greater-or-equal predicate without validating the fusion gate. See Self::filter_json_fused_text_eq_unchecked for the contract.

Source

pub fn filter_json_fused_timestamp_lt_unchecked( self, path: impl Into<String>, value: i64, ) -> Self

Append a fused JSON timestamp-less-than predicate without validating the fusion gate. See Self::filter_json_fused_text_eq_unchecked for the contract.

Source

pub fn filter_json_fused_timestamp_lte_unchecked( self, path: impl Into<String>, value: i64, ) -> Self

Append a fused JSON timestamp-less-or-equal predicate without validating the fusion gate. See Self::filter_json_fused_text_eq_unchecked for the contract.

Source

pub fn filter_json_fused_bool_eq_unchecked( self, path: impl Into<String>, value: bool, ) -> Self

Append a fused JSON boolean-equality predicate without validating the fusion gate. See Self::filter_json_fused_text_eq_unchecked for the contract.

Source

pub fn filter_json_fused_text_in_unchecked( self, path: impl Into<String>, values: Vec<String>, ) -> Self

Append a fused JSON text IN-set predicate without validating the fusion gate. See Self::filter_json_fused_text_eq_unchecked for the contract.

§Panics

Panics if values is empty — SQLite IN with an empty list is a syntax error.

Source

pub fn filter_json_text_in( self, path: impl Into<String>, values: Vec<String>, ) -> Self

Filter results where a JSON text property at path is one of values.

This is the non-fused variant; the predicate is applied as a residual WHERE clause. No FTS schema is required.

§Panics

Panics if values is empty — SQLite IN with an empty list is a syntax error.

Source

pub fn expand( self, slot: impl Into<String>, direction: TraverseDirection, label: impl Into<String>, max_depth: usize, filter: Option<Predicate>, edge_filter: Option<Predicate>, ) -> Self

Add an expansion slot that traverses edges of the given label for each root result.

Pass filter: None to preserve the existing behavior. filter: Some(_) is accepted by the AST but the compilation is not yet implemented (Pack 3). Pass edge_filter: None to preserve pre-Pack-D behavior (no edge filtering). edge_filter: Some(EdgePropertyEq { .. }) filters traversed edges by their JSON properties; only edges matching the predicate are followed.

Source

pub fn traverse_edges( self, slot: impl Into<String>, direction: TraverseDirection, label: impl Into<String>, max_depth: usize, ) -> EdgeExpansionBuilder

Begin registering an edge-projecting expansion slot. Chain EdgeExpansionBuilder::edge_filter / EdgeExpansionBuilder::endpoint_filter to attach predicates, then call EdgeExpansionBuilder::done to return this builder.

Emits (EdgeRow, NodeRow) tuples per root on execution. The endpoint node is the target on Out traversal, source on In. Slot name must be unique across both node- and edge-expansions within the same query; collisions are reported by Self::compile_grouped.

Source

pub fn limit(self, limit: usize) -> Self

Set the maximum number of result rows.

Source

pub fn ast(&self) -> &QueryAst

Borrow the underlying QueryAst.

Source

pub fn into_ast(self) -> QueryAst

Consume the builder and return the underlying QueryAst.

Source

pub fn compile(&self) -> Result<CompiledQuery, CompileError>

Compile this builder’s AST into an executable CompiledQuery.

§Errors

Returns CompileError if the query violates structural constraints (e.g. too many traversal steps or too many bind parameters).

Source

pub fn compile_grouped(&self) -> Result<CompiledGroupedQuery, CompileError>

Compile this builder’s AST into an executable grouped query.

§Errors

Returns CompileError if the query violates grouped-query structural constraints such as duplicate slot names or excessive depth.

Trait Implementations§

Source§

impl Clone for QueryBuilder

Source§

fn clone(&self) -> QueryBuilder

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 QueryBuilder

Source§

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

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

impl PartialEq for QueryBuilder

Source§

fn eq(&self, other: &QueryBuilder) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for QueryBuilder

Source§

impl StructuralPartialEq for QueryBuilder

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