pub struct Query {
pub root: QueryNode,
}Expand description
Search query AST
Fields§
§root: QueryNodeRoot query node
Implementations§
Source§impl Query
impl Query
Sourcepub fn field_eq(field: impl Into<String>, value: impl Into<String>) -> Self
pub fn field_eq(field: impl Into<String>, value: impl Into<String>) -> Self
Create a field equals query: @field:value
Create a tag query: @tags:{value1|value2}
Sourcepub fn numeric_range(
field: impl Into<String>,
min: Option<f64>,
max: Option<f64>,
) -> Self
pub fn numeric_range( field: impl Into<String>, min: Option<f64>, max: Option<f64>, ) -> Self
Create a numeric range query: @age:[min max]
Sourcepub fn text_search(field: impl Into<String>, text: impl Into<String>) -> Self
pub fn text_search(field: impl Into<String>, text: impl Into<String>) -> Self
Create a full-text search query (contains)
Sourcepub fn prefix(field: impl Into<String>, prefix: impl Into<String>) -> Self
pub fn prefix(field: impl Into<String>, prefix: impl Into<String>) -> Self
Create a prefix match query: @field:prefix*
Sourcepub fn fuzzy(field: impl Into<String>, text: impl Into<String>) -> Self
pub fn fuzzy(field: impl Into<String>, text: impl Into<String>) -> Self
Create a fuzzy match query: @field:%value%
Sourcepub fn vector(field: impl Into<String>, vector: Vec<f32>, k: usize) -> Self
pub fn vector(field: impl Into<String>, vector: Vec<f32>, k: usize) -> Self
Create a vector similarity (KNN) search query.
Returns the k nearest neighbors by vector similarity.
§Arguments
field- The vector field name (must be indexed with vector_hnsw/vector_flat)vector- Query embedding vector (must match field dimensionality)k- Number of nearest neighbors to return
§Example
ⓘ
let embedding = vec![0.1, 0.2, 0.3, /* ... 1536 dims for OpenAI */];
let query = Query::vector("embedding", embedding, 10);
let results = engine.search("documents", &query).await?;Sourcepub fn vector_filtered(
filter: Query,
field: impl Into<String>,
vector: Vec<f32>,
k: usize,
) -> Self
pub fn vector_filtered( filter: Query, field: impl Into<String>, vector: Vec<f32>, k: usize, ) -> Self
Create a filtered vector search query.
Combines a filter query with vector KNN search. The filter is applied first, then KNN is performed on the filtered results.
§Example
ⓘ
let embedding = get_embedding("semantic search query");
let query = Query::vector_filtered(
Query::tags("category", vec!["tech".into()]),
"embedding",
embedding,
10
);Trait Implementations§
Source§impl<'de> Deserialize<'de> for Query
impl<'de> Deserialize<'de> for Query
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Query
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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 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>
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