pub struct Filter {
pub must: Vec<Condition>,
pub should: Vec<Condition>,
pub must_not: Vec<Condition>,
}Expand description
A Boolean point filter.
Every must condition and no must_not condition must match. When should
is non-empty, at least one should condition must also match.
Fields§
§must: Vec<Condition>Conditions that must all match.
should: Vec<Condition>Conditions of which at least one must match when the list is non-empty.
must_not: Vec<Condition>Conditions that must not match.
Implementations§
Source§impl Filter
impl Filter
Sourcepub fn must(conditions: impl IntoIterator<Item = Condition>) -> Self
pub fn must(conditions: impl IntoIterator<Item = Condition>) -> Self
Creates a filter containing only required conditions.
Examples found in repository?
More examples
examples/filtering.rs (line 13)
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}Trait Implementations§
Source§impl<'de> Deserialize<'de> for Filter
impl<'de> Deserialize<'de> for Filter
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
Auto Trait Implementations§
impl Freeze for Filter
impl RefUnwindSafe for Filter
impl Send for Filter
impl Sync for Filter
impl Unpin for Filter
impl UnsafeUnpin for Filter
impl UnwindSafe for Filter
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
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> ⓘ
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