Skip to main content

QueryRequest

Struct QueryRequest 

Source
pub struct QueryRequest<'a> { /* private fields */ }
Expand description

Fluent builder for Laser::query. Accumulates a Query, then .fetch() returns the paged result, .fetch_typed::<T>() deserializes every row’s payload into T, .fetch_one::<T>() is the same but for at most one row.

Implementations§

Source§

impl<'a> QueryRequest<'a>

Source

pub fn deadline(self, timeout: Duration) -> Self

Set the absolute execution budget from now. The deadline applies to all pages under this query identity and is never extended by the server. The longest budget is 25 seconds. A longer one fails the fetch.

Source

pub fn deadline_micros(self, deadline_micros: u64) -> Self

Replace the absolute execution deadline, in Unix epoch microseconds. A caller that already holds a deadline passes it through unchanged instead of converting it back into a relative budget.

Source

pub const fn execution_id(&self) -> QueryExecutionId

The identity shared by execution, cursor pages, status, and cancellation.

Source

pub async fn status(&self) -> Result<QueryExecutionStatus, LaserError>

Read the current execution state for this query identity.

Source

pub async fn cancel(&self) -> Result<QueryExecutionStatus, LaserError>

Request cancellation for this query identity and return its observed state.

Source

pub fn at_snapshot(self, snapshot_id: i64) -> Result<Self, LaserError>

Select one exact Iceberg snapshot for a lakehouse query.

Source

pub fn at_timestamp_micros( self, timestamp_micros: i64, ) -> Result<Self, LaserError>

Select the retained Iceberg snapshot current at a timestamp.

Source

pub fn where_eq( self, field: impl Into<String>, value: impl Into<TypedValue>, ) -> Self

Exact-match on an indexed field (point lookup).

Source

pub fn conversation(self, conversation: ConversationId) -> Self

Narrow to the rows a single conversation produced (the conversation lens): an exact-match on the auto-projected CONVERSATION_FIELD, which a deployment materializes from every message’s gen_ai.conversation.id header. No producer-side index header is needed, so this works on any projection. Sugar over where_eq.

Source

pub fn fork(self, fork_id: impl Into<String>) -> Self

Resolve this query against a fork’s copy-on-write view (the trunk overlaid with the fork’s speculative rows) instead of the trunk. Open the fork with Laser::fork.

Source

pub fn filter_eq( self, field: impl Into<String>, value: impl Into<TypedValue>, ) -> Self

Filter rows where field == value.

Source

pub fn filter_ne( self, field: impl Into<String>, value: impl Into<TypedValue>, ) -> Self

Filter rows where field != value.

Source

pub fn filter_gt( self, field: impl Into<String>, value: impl Into<TypedValue>, ) -> Self

Filter rows where field > value (numeric if both parse as numbers, else lexical).

Source

pub fn filter_gte( self, field: impl Into<String>, value: impl Into<TypedValue>, ) -> Self

Filter rows where field >= value.

Source

pub fn filter_lt( self, field: impl Into<String>, value: impl Into<TypedValue>, ) -> Self

Filter rows where field < value.

Source

pub fn filter_lte( self, field: impl Into<String>, value: impl Into<TypedValue>, ) -> Self

Filter rows where field <= value.

Source

pub fn filter_in<T: Into<TypedValue>>( self, field: impl Into<String>, values: impl IntoIterator<Item = T>, ) -> Self

Filter rows where field is one of the given values.

Source

pub fn filter_contains( self, field: impl Into<String>, value: impl Into<String>, ) -> Self

Filter rows where field contains value (substring).

Source

pub fn filter_prefix( self, field: impl Into<String>, value: impl Into<String>, ) -> Self

Filter rows where field starts with value.

Source

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

Filter on agdx.idx.message_type.

Source

pub fn time_range(self, start: u64, end: u64) -> Self

Filter rows whose agdx.idx.ts (epoch micros) falls in [start, end], both bounds inclusive.

Source

pub fn order_asc(self, field: impl Into<String>) -> Self

Sort ascending by field (numeric-then-lexical).

Source

pub fn order_desc(self, field: impl Into<String>) -> Self

Sort descending by field (numeric-then-lexical).

Source

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

Limit the page to n rows. Zero or above MAX_PAGE_SIZE is rejected as LaserError::Invalid before the request is sent.

Source

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

Resume from an opaque cursor that the server returned in a previous page. Replaces any offset.

Source

pub fn offset(self, n: usize) -> Self

Skip the first n matching rows.

Source

pub fn with_payload(self) -> Self

Return the opaque payload bytes on each row (so you can decode them).

Source

pub fn with_total(self) -> Self

Request an exact page.total (a COUNT(*) on the server). Default off: without it, page.total is None and page.has_more is still exact. Ask for this only when the exact count itself matters (e.g. rendering “page 3 of 12”), it costs a full-table scan on a wide filter.

Source

pub fn read_your_writes(self) -> Self

Require read-your-writes: wait for the projector to apply the source log up to its current head before serving, so this query sees writes that completed before it. Bounded: if the projector cannot catch up in time the query returns QueryError::Stale (LaserError::is_stale()) instead of silently serving older data. Backend-gated: a deployment that cannot honor it returns Unsupported.

Source

pub fn consistency(self, level: Consistency) -> Self

Set the read-consistency level explicitly (Eventual is the default, ReadYourWrites, or Strong). Strong is gated by strong_consistency.

Source

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

Lexical relevance search over every text-hinted indexed field. Relevance lands in each row’s score exactly as vector distance does. Gated by the keyword capability: refused locally when unadvertised, so an unaware backend can never silently drop the filter.

Source

pub fn text_in(self, field: impl Into<String>, query: impl Into<String>) -> Self

Lexical relevance search narrowed to one indexed field.

Source

pub fn select_fields<S: Into<String>>( self, fields: impl IntoIterator<Item = S>, ) -> Self

Project only the named indexed fields into each result row.

Source

pub fn count(self) -> Self

Aggregate: row count, output in the count result field.

Source

pub fn sum(self, field: impl Into<String>) -> Self

Aggregate: sum of field, output in the sum result field.

Source

pub fn avg(self, field: impl Into<String>) -> Self

Aggregate: arithmetic mean of field, output in the avg result field.

Source

pub fn min(self, field: impl Into<String>) -> Self

Aggregate: minimum of field, output in the min result field.

Source

pub fn max(self, field: impl Into<String>) -> Self

Aggregate: maximum of field, output in the max result field.

Source

pub fn count_distinct(self, field: impl Into<String>) -> Self

Aggregate: distinct count of field, output in the result field count_distinct.

Source

pub fn stddev(self, field: impl Into<String>) -> Self

Aggregate: population standard deviation of field, output in the stddev result field. Backend-gated (columnar backends only).

Source

pub fn percentile(self, field: impl Into<String>, fraction: f64) -> Self

Aggregate: the fraction quantile of field (e.g. 0.95 for p95), output in the percentile result field. Backend-gated (columnar backends only).

Source

pub fn agg_as( self, func: AggFunc, field: Option<String>, fraction: Option<f64>, alias: impl Into<String>, ) -> Self

Add an aggregate with an explicit output alias. Use to return several aggregates of the same kind in one query, or to name the output column.

Source

pub fn group_by<S: Into<String>>( self, fields: impl IntoIterator<Item = S>, ) -> Self

Group the aggregate by the named fields.

Source

pub fn window(self, field: impl Into<String>, every_micros: u64) -> Self

Bucket the aggregate into tumbling windows of every_micros over the timestamp field. Each result row carries a window_start header (the bucket’s lower edge in epoch micros).

Source

pub fn having(self, filter: Filter) -> Self

Keep only aggregate groups matching filter. Predicate fields reference an aggregate alias (e.g. count) or a group key, not raw row fields.

Source

pub fn distinct(self) -> Self

Return only distinct rows over the projected fields. Requires select_fields.

Source

pub fn raw_sql(self, dialect: SqlDialect, sql: impl Into<String>) -> Self

Opt-in raw-SQL escape hatch: run sql (a single read-only SELECT) on the index’s backend. SQL backends only, not portable. Result columns come back as typed positional values aligned with the result fields.

Source

pub fn raw_sql_with<V: Into<TypedValue>>( self, dialect: SqlDialect, sql: impl Into<String>, params: impl IntoIterator<Item = V>, ) -> Self

Like raw_sql but with positional bind params.

Source

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

Approximate nearest-neighbour search against the default vector field (VECTOR_FIELD = "embedding"). Use nearest_in to point at a different field name.

Source

pub fn nearest_in( self, field: impl Into<String>, embedding: Vec<f32>, top_k: usize, ) -> Self

Approximate nearest-neighbour search on an explicit field. Use when your projector stores the vector under a custom payload key.

Source

pub async fn fetch(self) -> Result<QueryResult, LaserError>

Run the query and return the paged result + metadata.

Source

pub async fn fetch_typed<T: DeserializeOwned>( self, ) -> Result<Vec<T>, LaserError>

Run the query, then deserialize every row’s payload into T (JSON). with_payload() is implied. Single-page only: use .stream_typed() or .fetch_all_typed() if there may be more than MAX_PAGE_SIZE matches.

Source

pub async fn fetch_one<T: DeserializeOwned>( self, ) -> Result<Option<T>, LaserError>

Like fetch_typed but caps the result at one row.

Source

pub async fn fetch_typed_with<C, T>(self) -> Result<Vec<T>, LaserError>
where C: Decoder<T>,

Like fetch_typed but decode each row’s payload with any Decoder (Json, Msgpack, or your own codec) instead of being locked to JSON. with_payload() is implied.

let readings: Vec<Reading> = laser.query("readings").fetch_typed_with::<Msgpack, _>().await?;
Source

pub async fn fetch_one_with<C, T>(self) -> Result<Option<T>, LaserError>
where C: Decoder<T>,

Like fetch_one but decode the row with any Decoder instead of JSON.

Source

pub fn max_rows(self, n: usize) -> Self

Cap the total rows a rows walk may yield. Explicit by design (the bounded-reads law): a paged walk with no ceiling is an unbounded read dressed as a stream, so the ceiling is the caller writing a number, never a silent default.

Source

pub fn rows(self) -> Result<QueryRows<'a>, LaserError>

Walk matching rows across pages, bounded by an explicit max_rows. Each .next().await yields the next row and the walk stops at the cap or the last page, whichever comes first. The grammar’s streaming terminal, mirroring the kv scan’s .entries().

let mut rows = laser.query("readings").where_eq("status", "degraded").max_rows(1_000).rows()?;
while let Some(row) = rows.next().await? {
    let _ = row;
}
Source

pub fn rows_typed<T: DeserializeOwned>( self, ) -> Result<TypedQueryRows<'a, T>, LaserError>

Like rows but each yield is T decoded from the row’s payload, under the same explicit max_rows ceiling. with_payload() is implied, and the publisher must have chained .inline_payload() for the bytes to be there.

Source

pub async fn fetch_all(self) -> Result<Vec<Row>, LaserError>

Materialize EVERY matching row by walking pages internally: the explicit full-result opt-in. Convenient when you need them all and the working set fits comfortably in memory. Prefer the bounded rows walk when it might not.

Source

pub async fn fetch_all_typed<T: DeserializeOwned>( self, ) -> Result<Vec<T>, LaserError>

Materialize EVERY matching row, decoded into T: the explicit full-result opt-in, see fetch_all.

Source

pub fn into_query(self) -> Query

Inspect the raw Query the builder produced (debugging).

Source

pub fn filter(self, filter: Filter) -> Self

AND filter into the query’s predicate tree. The fluent filter_* helpers route through here, so chained filters compose as a conjunction. Build Any/Not subtrees with Filter::any/Filter::negate and pass them here.

Trait Implementations§

Source§

impl<'a> From<QueryRequest<'a>> for Query

Source§

fn from(request: QueryRequest<'a>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for QueryRequest<'a>

§

impl<'a> !UnwindSafe for QueryRequest<'a>

§

impl<'a> Freeze for QueryRequest<'a>

§

impl<'a> Send for QueryRequest<'a>

§

impl<'a> Sync for QueryRequest<'a>

§

impl<'a> Unpin for QueryRequest<'a>

§

impl<'a> UnsafeUnpin for QueryRequest<'a>

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> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. 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<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