Predicate

Enum Predicate 

Source
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}

Fields

§field: String
§words: Vec<String>
§slop: Option<u32>
§inorder: Option<bool>
§

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

Fields

§field: String
§points: Vec<(f64, f64)>

Points as (lon, lat) pairs forming a closed polygon

§

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

§field: String
§vector_param: String

Vector as bytes (to be passed as PARAMS)

§pre_filter: Option<Box<Predicate>>

Optional pre-filter query

§

VectorRange

Vector range search: @field:[VECTOR_RANGE radius $vec]

Fields

§field: String
§radius: f64
§vector_param: String
§

Raw(String)

Raw RediSearch query (escape hatch)

Implementations§

Source§

impl Predicate

Source

pub fn eq(field: impl Into<String>, value: impl Into<Value>) -> Self

Create an equality predicate.

Source

pub fn ne(field: impl Into<String>, value: impl Into<Value>) -> Self

Create a not-equal predicate.

Source

pub fn gt(field: impl Into<String>, value: impl Into<Value>) -> Self

Create a greater-than predicate.

Source

pub fn gte(field: impl Into<String>, value: impl Into<Value>) -> Self

Create a greater-than-or-equal predicate.

Source

pub fn lt(field: impl Into<String>, value: impl Into<Value>) -> Self

Create a less-than predicate.

Source

pub fn lte(field: impl Into<String>, value: impl Into<Value>) -> Self

Create a less-than-or-equal predicate.

Source

pub fn between( field: impl Into<String>, min: impl Into<Value>, max: impl Into<Value>, ) -> Self

Create a between predicate (inclusive).

Create a full-text search predicate.

Source

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

Create a prefix match predicate.

Source

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

Create a suffix match predicate.

Source

pub fn infix(field: impl Into<String>, substring: impl Into<String>) -> Self

Create an infix/contains match predicate: *substring*

Source

pub fn wildcard(field: impl Into<String>, pattern: impl Into<String>) -> Self

Create a wildcard match predicate with simple wildcards.

Source

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.

Source

pub fn fuzzy( field: impl Into<String>, term: impl Into<String>, distance: u8, ) -> Self

Create a fuzzy match predicate.

Source

pub fn phrase(field: impl Into<String>, words: Vec<impl Into<String>>) -> Self

Create a phrase search predicate.

Source

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 search
  • words - Words that should appear in the phrase
  • slop - Number of intervening terms allowed (None = exact match)
  • inorder - Whether words must appear in order (None = any order)
Source

pub fn optional(self) -> Self

Mark a predicate as optional (boosts score but not required). Generates: ~(query)

Source

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

Create a tag match predicate.

Source

pub fn tag_or(field: impl Into<String>, tags: Vec<impl Into<String>>) -> Self

Create a tag OR predicate.

Create a multi-field text search: @field1|field2:term

Source

pub fn geo_radius( field: impl Into<String>, lon: f64, lat: f64, radius: f64, unit: impl Into<String>, ) -> Self

Create a geo radius predicate.

Source

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

Source

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 name
  • k - Number of nearest neighbors to return
  • vector_param - Parameter name for the vector (will be passed via PARAMS)
Source

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.

Source

pub fn vector_range( field: impl Into<String>, radius: f64, vector_param: impl Into<String>, ) -> Self

Create a vector range search predicate.

Source

pub fn is_missing(field: impl Into<String>) -> Self

Check if field is missing.

Source

pub fn is_not_missing(field: impl Into<String>) -> Self

Check if field exists.

Source

pub fn raw(query: impl Into<String>) -> Self

Create a raw RediSearch query.

Source

pub fn and(self, other: Predicate) -> Self

Combine with AND.

Source

pub fn or(self, other: Predicate) -> Self

Combine with OR.

Source

pub fn negate(self) -> Self

Negate this predicate.

Source

pub fn boost(self, weight: f64) -> Self

Boost this predicate’s relevance score.

Source

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.

Source

pub fn to_query(&self) -> String

Convert to RediSearch query string.

Trait Implementations§

Source§

impl Clone for Predicate

Source§

fn clone(&self) -> Predicate

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 Predicate

Source§

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

Formats the value using the given formatter. Read more

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

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,