#[non_exhaustive]pub enum Condition {
HasField {
has_field: String,
},
FieldIn {
key: String,
any: Vec<Value>,
},
FieldNotIn {
key: String,
none: Vec<Value>,
},
FieldContains {
key: String,
contains: Value,
},
DocumentContains {
document_contains: String,
},
DocumentRegex {
document_regex: String,
},
Field {
key: String,
matches: Option<MatchValue>,
range: Option<Range>,
},
HasId {
has_id: Vec<PointId>,
},
Nested(Filter),
}Expand description
A predicate used inside a Filter.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
HasField
Matches when a dot-separated payload field exists.
FieldIn
Matches when a scalar payload field is one of the supplied values.
FieldNotIn
Matches when a scalar payload field is not one of the supplied values.
FieldContains
Matches when an array payload field contains the supplied scalar value.
DocumentContains
Matches when the reserved stored document contains a substring.
DocumentRegex
Matches when the reserved stored document satisfies a regular expression.
Field
Matches or range-checks a dot-separated payload field.
Fields
matches: Option<MatchValue>Optional equality match.
HasId
Matches points whose typed ID is in the supplied set.
Nested(Filter)
Evaluates a nested Boolean filter.
Implementations§
Source§impl Condition
impl Condition
Sourcepub fn matches(key: impl Into<String>, value: impl Into<Value>) -> Self
pub fn matches(key: impl Into<String>, value: impl Into<Value>) -> Self
Creates an equality condition for a dot-separated payload path.
Examples found in repository?
4fn main() -> git_vdb::Result<()> {
5 let temporary = tempfile::TempDir::new()?;
6 let docs = open(temporary.path().join("vectors.git"))?.collection("docs");
7 docs.upsert([
8 Point::new("guide", [1.0, 0.0]).with_metadata(json!({"kind": "docs"}))?,
9 Point::new("code", [0.9, 0.1]).with_metadata(json!({"kind": "source"}))?,
10 ])?;
11 let result = docs.advanced()?.query(
12 Query::new([1.0, 0.0], 5)
13 .with_filter(Filter::must([Condition::matches("kind", "docs")]))
14 .with_payload(),
15 )?;
16 assert_eq!(result.points[0].id.to_string(), "guide");
17 Ok(())
18}Sourcepub fn range(key: impl Into<String>, range: Range) -> Self
pub fn range(key: impl Into<String>, range: Range) -> Self
Creates a numeric-range condition for a dot-separated payload path.
Sourcepub fn has_id(ids: impl IntoIterator<Item = PointId>) -> Self
pub fn has_id(ids: impl IntoIterator<Item = PointId>) -> Self
Creates a condition that accepts the supplied typed point IDs.
Sourcepub fn exists(key: impl Into<String>) -> Self
pub fn exists(key: impl Into<String>) -> Self
Creates a condition requiring a dot-separated payload path to exist.
Sourcepub fn is_in(
key: impl Into<String>,
values: impl IntoIterator<Item = Value>,
) -> Self
pub fn is_in( key: impl Into<String>, values: impl IntoIterator<Item = Value>, ) -> Self
Creates a condition accepting any of a set of scalar field values.
Sourcepub fn not_in(
key: impl Into<String>,
values: impl IntoIterator<Item = Value>,
) -> Self
pub fn not_in( key: impl Into<String>, values: impl IntoIterator<Item = Value>, ) -> Self
Creates a condition rejecting a set of scalar field values.
Sourcepub fn contains(key: impl Into<String>, value: impl Into<Value>) -> Self
pub fn contains(key: impl Into<String>, value: impl Into<Value>) -> Self
Creates a condition requiring an array field to contain a scalar value.
Sourcepub fn document_contains(value: impl Into<String>) -> Self
pub fn document_contains(value: impl Into<String>) -> Self
Creates a case-sensitive substring condition over the stored document.
Sourcepub fn document_regex(value: impl Into<String>) -> Self
pub fn document_regex(value: impl Into<String>) -> Self
Creates a regular-expression condition over the stored document.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Condition
impl<'de> Deserialize<'de> for Condition
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 Condition
impl RefUnwindSafe for Condition
impl Send for Condition
impl Sync for Condition
impl Unpin for Condition
impl UnsafeUnpin for Condition
impl UnwindSafe for Condition
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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