pub enum FilterExpr {
And(Box<FilterExpr>, Box<FilterExpr>),
Or(Box<FilterExpr>, Box<FilterExpr>),
Not(Box<FilterExpr>),
Compare {
field: String,
op: FilterOp,
value: Value,
},
Exists(String),
All,
None,
}Expand description
Filter expression for metadata-based filtering
Supports composable boolean logic (AND, OR, NOT) and various comparison operators for flexible query filtering.
§Example
use embedvec::FilterExpr;
let filter = FilterExpr::eq("category", "finance")
.and(FilterExpr::gt("timestamp", 1730000000))
.and(FilterExpr::not(FilterExpr::eq("status", "archived")));Variants§
And(Box<FilterExpr>, Box<FilterExpr>)
Logical AND of two expressions
Or(Box<FilterExpr>, Box<FilterExpr>)
Logical OR of two expressions
Not(Box<FilterExpr>)
Logical NOT of an expression
Compare
Comparison operation on a field
Fields
Exists(String)
Check if field exists
All
Always true (no filter)
None
Always false (match nothing)
Implementations§
Source§impl FilterExpr
impl FilterExpr
Sourcepub fn eq(field: impl Into<String>, value: impl Into<Value>) -> Self
pub fn eq(field: impl Into<String>, value: impl Into<Value>) -> Self
Create an equality filter: field == value
Sourcepub fn neq(field: impl Into<String>, value: impl Into<Value>) -> Self
pub fn neq(field: impl Into<String>, value: impl Into<Value>) -> Self
Create a not-equal filter: field != value
Sourcepub fn gt(field: impl Into<String>, value: impl Into<Value>) -> Self
pub fn gt(field: impl Into<String>, value: impl Into<Value>) -> Self
Create a greater-than filter: field > value
Sourcepub fn gte(field: impl Into<String>, value: impl Into<Value>) -> Self
pub fn gte(field: impl Into<String>, value: impl Into<Value>) -> Self
Create a greater-than-or-equal filter: field >= value
Sourcepub fn lt(field: impl Into<String>, value: impl Into<Value>) -> Self
pub fn lt(field: impl Into<String>, value: impl Into<Value>) -> Self
Create a less-than filter: field < value
Sourcepub fn lte(field: impl Into<String>, value: impl Into<Value>) -> Self
pub fn lte(field: impl Into<String>, value: impl Into<Value>) -> Self
Create a less-than-or-equal filter: field <= value
Sourcepub fn in_values(field: impl Into<String>, values: Vec<Value>) -> Self
pub fn in_values(field: impl Into<String>, values: Vec<Value>) -> Self
Create an “in” filter: field in [values…]
Sourcepub fn contains(field: impl Into<String>, substring: impl Into<String>) -> Self
pub fn contains(field: impl Into<String>, substring: impl Into<String>) -> Self
Create a contains filter: field contains substring
Sourcepub fn starts_with(field: impl Into<String>, prefix: impl Into<String>) -> Self
pub fn starts_with(field: impl Into<String>, prefix: impl Into<String>) -> Self
Create a starts-with filter
Sourcepub fn ends_with(field: impl Into<String>, suffix: impl Into<String>) -> Self
pub fn ends_with(field: impl Into<String>, suffix: impl Into<String>) -> Self
Create an ends-with filter
Sourcepub fn not(expr: FilterExpr) -> Self
pub fn not(expr: FilterExpr) -> Self
Create a NOT expression
Sourcepub fn and(self, other: FilterExpr) -> Self
pub fn and(self, other: FilterExpr) -> Self
Combine with AND
Sourcepub fn or(self, other: FilterExpr) -> Self
pub fn or(self, other: FilterExpr) -> Self
Combine with OR
Trait Implementations§
Source§impl Clone for FilterExpr
impl Clone for FilterExpr
Source§fn clone(&self) -> FilterExpr
fn clone(&self) -> FilterExpr
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FilterExpr
impl Debug for FilterExpr
Source§impl<'de> Deserialize<'de> for FilterExpr
impl<'de> Deserialize<'de> for FilterExpr
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>,
Auto Trait Implementations§
impl Freeze for FilterExpr
impl RefUnwindSafe for FilterExpr
impl Send for FilterExpr
impl Sync for FilterExpr
impl Unpin for FilterExpr
impl UnsafeUnpin for FilterExpr
impl UnwindSafe for FilterExpr
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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