pub enum Predicate {
Show 31 variants
Eq(String, Value),
Ne(String, Value),
Gt(String, Value),
Gte(String, Value),
Lt(String, Value),
Lte(String, Value),
Between(String, Value, Value),
And(Vec<Predicate>),
Or(Vec<Predicate>),
Not(Box<Predicate>),
TextSearch(String, String),
Prefix(String, String),
Suffix(String, String),
Infix(String, String),
Wildcard(String, String),
WildcardExact(String, String),
Fuzzy(String, String, u8),
Phrase(String, Vec<String>),
PhraseWithOptions {
field: String,
words: Vec<String>,
slop: Option<u32>,
inorder: Option<bool>,
},
Optional(Box<Predicate>),
Tag(String, String),
TagOr(String, Vec<String>),
MultiFieldSearch(Vec<String>, String),
GeoRadius(String, f64, f64, f64, String),
GeoPolygon {
field: String,
points: Vec<(f64, f64)>,
},
IsMissing(String),
IsNotMissing(String),
Boost(Box<Predicate>, f64),
VectorKnn {
field: String,
k: usize,
vector_param: String,
pre_filter: Option<Box<Predicate>>,
},
VectorRange {
field: String,
radius: f64,
vector_param: String,
},
Raw(String),
}Expand description
A single predicate that can be translated to RediSearch.
Variants§
Eq(String, Value)
Equality: @field:{value} for TAG, @field:[value value] for NUMERIC
Ne(String, Value)
Not equal: -@field:{value}
Gt(String, Value)
Greater than: @field:[(value +inf]
Gte(String, Value)
Greater than or equal: @field:[value +inf]
Lt(String, Value)
Less than: @field:[-inf (value]
Lte(String, Value)
Less than or equal: @field:[-inf value]
Between(String, Value, Value)
Between (inclusive): @field:[min max]
And(Vec<Predicate>)
AND of multiple predicates
Or(Vec<Predicate>)
OR of multiple predicates
Not(Box<Predicate>)
NOT: -(query)
TextSearch(String, String)
Full-text search: @field:term
Prefix(String, String)
Prefix match: @field:prefix*
Suffix(String, String)
Suffix match: @field:*suffix
Infix(String, String)
Infix/contains match: @field:*substring*
Wildcard(String, String)
Wildcard match: @field:pattern
WildcardExact(String, String)
Exact wildcard match: @field:"w'pattern'"
Fuzzy(String, String, u8)
Fuzzy match: @field:%term% (distance 1), @field:%%term%% (distance 2)
Phrase(String, Vec<String>)
Phrase search: @field:(word1 word2 word3)
PhraseWithOptions
Phrase search with slop and inorder: @field:(word1 word2)=>{$slop:2;$inorder:true}
Optional(Box<Predicate>)
Optional term: ~@field:term (boosts score but not required)
Tag(String, String)
Tag match: @field:{tag}
TagOr(String, Vec<String>)
Tag OR: @field:{tag1|tag2|tag3}
MultiFieldSearch(Vec<String>, String)
Search across multiple fields: @field1|field2|field3:term
GeoRadius(String, f64, f64, f64, String)
Geo radius: @field:[lon lat radius unit]
GeoPolygon
Geo polygon filter using WITHIN
IsMissing(String)
Field is missing: ismissing(@field)
IsNotMissing(String)
Field exists: -ismissing(@field)
Boost(Box<Predicate>, f64)
Boost: (query) => { $weight: value; }
VectorKnn
KNN vector search: *=>[KNN k @field $vec]
Fields
VectorRange
Vector range search: @field:[VECTOR_RANGE radius $vec]
Raw(String)
Raw RediSearch query (escape hatch)
Implementations§
Source§impl Predicate
impl Predicate
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 predicate.
Sourcepub fn ne(field: impl Into<String>, value: impl Into<Value>) -> Self
pub fn ne(field: impl Into<String>, value: impl Into<Value>) -> Self
Create a not-equal predicate.
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 predicate.
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 predicate.
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 predicate.
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 predicate.
Sourcepub fn between(
field: impl Into<String>,
min: impl Into<Value>,
max: impl Into<Value>,
) -> Self
pub fn between( field: impl Into<String>, min: impl Into<Value>, max: impl Into<Value>, ) -> Self
Create a between predicate (inclusive).
Sourcepub fn text_search(field: impl Into<String>, term: impl Into<String>) -> Self
pub fn text_search(field: impl Into<String>, term: impl Into<String>) -> Self
Create a full-text search predicate.
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 predicate.
Sourcepub fn suffix(field: impl Into<String>, suffix: impl Into<String>) -> Self
pub fn suffix(field: impl Into<String>, suffix: impl Into<String>) -> Self
Create a suffix match predicate.
Sourcepub fn infix(field: impl Into<String>, substring: impl Into<String>) -> Self
pub fn infix(field: impl Into<String>, substring: impl Into<String>) -> Self
Create an infix/contains match predicate: *substring*
Sourcepub fn wildcard(field: impl Into<String>, pattern: impl Into<String>) -> Self
pub fn wildcard(field: impl Into<String>, pattern: impl Into<String>) -> Self
Create a wildcard match predicate with simple wildcards.
Sourcepub fn wildcard_exact(
field: impl Into<String>,
pattern: impl Into<String>,
) -> Self
pub fn wildcard_exact( field: impl Into<String>, pattern: impl Into<String>, ) -> Self
Create an exact wildcard match predicate: w'pattern'
Supports * (any chars) and ? (single char) wildcards.
Sourcepub fn fuzzy(
field: impl Into<String>,
term: impl Into<String>,
distance: u8,
) -> Self
pub fn fuzzy( field: impl Into<String>, term: impl Into<String>, distance: u8, ) -> Self
Create a fuzzy match predicate.
Sourcepub fn phrase(field: impl Into<String>, words: Vec<impl Into<String>>) -> Self
pub fn phrase(field: impl Into<String>, words: Vec<impl Into<String>>) -> Self
Create a phrase search predicate.
Sourcepub fn phrase_with_options(
field: impl Into<String>,
words: Vec<impl Into<String>>,
slop: Option<u32>,
inorder: Option<bool>,
) -> Self
pub fn phrase_with_options( field: impl Into<String>, words: Vec<impl Into<String>>, slop: Option<u32>, inorder: Option<bool>, ) -> Self
Create a phrase search predicate with slop and inorder options.
§Arguments
field- The field to searchwords- Words that should appear in the phraseslop- Number of intervening terms allowed (None = exact match)inorder- Whether words must appear in order (None = any order)
Sourcepub fn optional(self) -> Self
pub fn optional(self) -> Self
Mark a predicate as optional (boosts score but not required).
Generates: ~(query)
Sourcepub fn tag(field: impl Into<String>, tag: impl Into<String>) -> Self
pub fn tag(field: impl Into<String>, tag: impl Into<String>) -> Self
Create a tag match predicate.
Sourcepub fn tag_or(field: impl Into<String>, tags: Vec<impl Into<String>>) -> Self
pub fn tag_or(field: impl Into<String>, tags: Vec<impl Into<String>>) -> Self
Create a tag OR predicate.
Sourcepub fn multi_field_search(
fields: Vec<impl Into<String>>,
term: impl Into<String>,
) -> Self
pub fn multi_field_search( fields: Vec<impl Into<String>>, term: impl Into<String>, ) -> Self
Create a multi-field text search: @field1|field2:term
Sourcepub fn geo_radius(
field: impl Into<String>,
lon: f64,
lat: f64,
radius: f64,
unit: impl Into<String>,
) -> Self
pub fn geo_radius( field: impl Into<String>, lon: f64, lat: f64, radius: f64, unit: impl Into<String>, ) -> Self
Create a geo radius predicate.
Sourcepub fn geo_polygon(field: impl Into<String>, points: Vec<(f64, f64)>) -> Self
pub fn geo_polygon(field: impl Into<String>, points: Vec<(f64, f64)>) -> Self
Create a geo polygon predicate. Points should form a closed polygon (first and last point should be the same).
Sourcepub fn vector_knn(
field: impl Into<String>,
k: usize,
vector_param: impl Into<String>,
) -> Self
pub fn vector_knn( field: impl Into<String>, k: usize, vector_param: impl Into<String>, ) -> Self
Create a KNN vector search predicate.
§Arguments
field- The vector field namek- Number of nearest neighbors to returnvector_param- Parameter name for the vector (will be passed via PARAMS)
Sourcepub fn vector_knn_with_filter(
field: impl Into<String>,
k: usize,
vector_param: impl Into<String>,
pre_filter: Predicate,
) -> Self
pub fn vector_knn_with_filter( field: impl Into<String>, k: usize, vector_param: impl Into<String>, pre_filter: Predicate, ) -> Self
Create a KNN vector search with pre-filter.
Sourcepub fn vector_range(
field: impl Into<String>,
radius: f64,
vector_param: impl Into<String>,
) -> Self
pub fn vector_range( field: impl Into<String>, radius: f64, vector_param: impl Into<String>, ) -> Self
Create a vector range search predicate.
Sourcepub fn is_missing(field: impl Into<String>) -> Self
pub fn is_missing(field: impl Into<String>) -> Self
Check if field is missing.
Sourcepub fn is_not_missing(field: impl Into<String>) -> Self
pub fn is_not_missing(field: impl Into<String>) -> Self
Check if field exists.
Sourcepub fn get_params(&self) -> Vec<(String, String)>
pub fn get_params(&self) -> Vec<(String, String)>
Get parameters that need to be passed to FT.SEARCH via PARAMS. Returns a list of (name, value) pairs.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Predicate
impl RefUnwindSafe for Predicate
impl Send for Predicate
impl Sync for Predicate
impl Unpin for Predicate
impl UnwindSafe for Predicate
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