diff --git a/src/builders/has_vector_condition_builder.rs b/src/builders/has_vector_condition_builder.rs deleted file mode 100644 index b449a8d..0000000 --- a/src/builders/has_vector_condition_builder.rs +++ /dev/null @@ -1,38 +0,0 @@ -use crate::qdrant::*; - -pub struct HasVectorConditionBuilder { - pub(crate) vector_name: String, -} - -impl HasVectorConditionBuilder { - pub fn new(vector_name: impl Into) -> Self { - Self { - vector_name: vector_name.into(), - } - } - - /// Builds the desired type. Can often be omitted. - fn build(self) -> HasVectorCondition { - HasVectorCondition { - has_vector: self.vector_name, - } - } -} - -impl From for HasVectorConditionBuilder { - fn from(vector_name: String) -> Self { - Self::new(vector_name) - } -} - -impl From for HasVectorCondition { - fn from(value: HasVectorConditionBuilder) -> Self { - value.build() - } -} - -impl From for HasVectorCondition { - fn from(vector_name: String) -> Self { - HasVectorConditionBuilder::from(vector_name).into() - } -} diff --git a/src/builders/mod.rs b/src/builders/mod.rs index 1d94883..b12cd57 100644 --- a/src/builders/mod.rs +++ b/src/builders/mod.rs @@ -217,9 +217,6 @@ pub use create_collection_builder::CreateCollectionBuilder; pub mod count_points_builder; pub use count_points_builder::*; -pub mod has_vector_condition_builder; -pub use has_vector_condition_builder::HasVectorConditionBuilder; - pub mod dense_vector_builder; pub use dense_vector_builder::DenseVectorBuilder; diff --git a/src/filters.rs b/src/filters.rs index f4d2256..8b9b91d 100644 --- a/src/filters.rs +++ b/src/filters.rs @@ -3,8 +3,8 @@ use crate::qdrant::points_selector::PointsSelectorOneOf; use crate::qdrant::r#match::MatchValue; use crate::qdrant::{ self, Condition, DatetimeRange, FieldCondition, Filter, GeoBoundingBox, GeoPolygon, GeoRadius, - HasIdCondition, IsEmptyCondition, IsNullCondition, MinShould, NestedCondition, PointId, - PointsSelector, Range, ValuesCount, + HasIdCondition, HasVectorCondition, IsEmptyCondition, IsNullCondition, MinShould, + NestedCondition, PointId, PointsSelector, Range, ValuesCount, }; impl From for PointsSelector { @@ -47,6 +47,14 @@ impl From for Condition { } } +impl From for Condition { + fn from(has_vector_condition: HasVectorCondition) -> Self { + Condition { + condition_one_of: Some(ConditionOneOf::HasVector(has_vector_condition)), + } + } +} + impl From for Condition { fn from(filter: Filter) -> Self { Condition { @@ -180,6 +188,18 @@ impl qdrant::Condition { }) } + /// Create a [`Condition`] to check if the point has a specific named vector. + /// + /// # Examples: + /// ``` + /// qdrant_client::qdrant::Condition::has_vector("my_vector"); + /// ``` + pub fn has_vector(vector_name: impl Into) -> Self { + Self::from(qdrant::HasVectorCondition { + has_vector: vector_name.into(), + }) + } + /// Create a [`Condition`] that matches a field against a certain value. /// /// # Examples: