Skip to content

Commit

Permalink
Update v1.6.0 (#72)
Browse files Browse the repository at this point in the history
* bump create version

* ignore intellij config file

* regen client

* update test image version

* add geo-polygon condition builder

* format example

* dependencies updates

* filter out new healcheck proto
  • Loading branch information
agourlay authored and timvisee committed Oct 9, 2023
1 parent 4372af6 commit 95212d1
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 29 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ Cargo.lock
/target

.idea
test.tar
test.tar
*.iml
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "qdrant-client"
version = "1.5.0"
version = "1.6.0"
edition = "2021"
authors = ["Qdrant Team <team@qdrant.com>"]
description = "Rust client for Qdrant Vector Search Engine"
Expand All @@ -18,12 +18,12 @@ anyhow = "1"

serde = { version = "1", features = ["derive"], optional = true }
serde_json = { version = "1", optional = true }
reqwest = { version = "0.11.18", optional = true, default-features = false, features = ["stream", "rustls-tls"] }
reqwest = { version = "0.11.22", optional = true, default-features = false, features = ["stream", "rustls-tls"] }
futures-util = { version = "0.3.28", optional = true }

[dev-dependencies]
tonic-build = { version = "0.9.2", features = ["prost"] }
tokio = { version = "1.29.1", features = ["rt-multi-thread"] }
tokio = { version = "1.32.0", features = ["rt-multi-thread"] }

[features]
default = ["download_snapshots", "serde"]
Expand Down
2 changes: 2 additions & 0 deletions proto/collections.proto
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,14 @@ message CollectionParams {
optional VectorsConfig vectors_config = 5; // Configuration for vectors
optional uint32 replication_factor = 6; // Number of replicas of each shard that network tries to maintain
optional uint32 write_consistency_factor = 7; // How many replicas should apply the operation for us to consider it successful
optional uint32 read_fan_out_factor = 8; // Fan-out every read request to these many additional remote nodes (and return first available response)
}

message CollectionParamsDiff {
optional uint32 replication_factor = 1; // Number of replicas of each shard that network tries to maintain
optional uint32 write_consistency_factor = 2; // How many replicas should apply the operation for us to consider it successful
optional bool on_disk_payload = 3; // If true - point's payload will not be stored in memory
optional uint32 read_fan_out_factor = 4; // Fan-out every read request to these many additional remote nodes (and return first available response)
}

message CollectionConfig {
Expand Down
42 changes: 32 additions & 10 deletions proto/points.proto
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ message QuantizationSearchParams {
optional bool ignore = 1;

/*
If true, use original vectors to re-score top-k results. Default is true.
If true, use original vectors to re-score top-k results. If ignored, qdrant decides automatically does rescore enabled or not.
*/
optional bool rescore = 2;

Expand Down Expand Up @@ -281,15 +281,27 @@ message ScrollPoints {
optional ReadConsistency read_consistency = 8; // Options for specifying read consistency guarantees
}

// How to use positive and negative vectors to find the results, default is `AverageVector`:
enum RecommendStrategy {
// Average positive and negative vectors and create a single query with the formula
// `query = avg_pos + avg_pos - avg_neg`. Then performs normal search.
AverageVector = 0;

// Uses custom search objective. Each candidate is compared against all
// examples, its score is then chosen from the `max(max_pos_score, max_neg_score)`.
// If the `max_neg_score` is chosen then it is squared and negated.
BestScore = 1;
}

message LookupLocation {
string collection_name = 1;
optional string vector_name = 2; // Which vector to use for search, if not specified - use default vector
}

message RecommendPoints {
string collection_name = 1; // name of the collection
repeated PointId positive = 2; // Look for vectors closest to those
repeated PointId negative = 3; // Try to avoid vectors like this
repeated PointId positive = 2; // Look for vectors closest to the vectors from these points
repeated PointId negative = 3; // Try to avoid vectors like the vector from these points
Filter filter = 4; // Filter conditions - return only those points that satisfy the specified conditions
uint64 limit = 5; // Max number of result
reserved 6; // deprecated "with_vector" field
Expand All @@ -301,6 +313,9 @@ message RecommendPoints {
optional WithVectorsSelector with_vectors = 12; // Options for specifying which vectors to include into response
optional LookupLocation lookup_from = 13; // Name of the collection to use for points lookup, if not specified - use current collection
optional ReadConsistency read_consistency = 14; // Options for specifying read consistency guarantees
optional RecommendStrategy strategy = 16; // How to use the example vectors to find the results
repeated Vector positive_vectors = 17; // Look for vectors closest to those
repeated Vector negative_vectors = 18; // Try to avoid vectors like this
}

message RecommendBatchPoints {
Expand All @@ -311,8 +326,8 @@ message RecommendBatchPoints {

message RecommendPointGroups {
string collection_name = 1; // Name of the collection
repeated PointId positive = 2; // Look for vectors closest to those
repeated PointId negative = 3; // Try to avoid vectors like this
repeated PointId positive = 2; // Look for vectors closest to the vectors from these points
repeated PointId negative = 3; // Try to avoid vectors like the vector from these points
Filter filter = 4; // Filter conditions - return only those points that satisfy the specified conditions
uint32 limit = 5; // Max number of groups in result
WithPayloadSelector with_payload = 6; // Options for specifying which payload to include or not
Expand All @@ -325,6 +340,9 @@ message RecommendPointGroups {
uint32 group_size = 13; // Maximum amount of points to return per group
optional ReadConsistency read_consistency = 14; // Options for specifying read consistency guarantees
optional WithLookup with_lookup = 15; // Options for specifying how to use the group id to lookup points in another collection
optional RecommendStrategy strategy = 17; // How to use the example vectors to find the results
repeated Vector positive_vectors = 18; // Look for vectors closest to those
repeated Vector negative_vectors = 19; // Try to avoid vectors like this
}

message CountPoints {
Expand Down Expand Up @@ -533,7 +551,7 @@ message FieldCondition {
GeoBoundingBox geo_bounding_box = 4; // Check if points geolocation lies in a given area
GeoRadius geo_radius = 5; // Check if geo point is within a given radius
ValuesCount values_count = 6; // Check number of values for a specific field
// GeoPolygon geo_polygon = 7; // Check if geo point is within a given polygon
GeoPolygon geo_polygon = 7; // Check if geo point is within a given polygon
}

message Match {
Expand Down Expand Up @@ -574,11 +592,15 @@ message GeoRadius {
float radius = 2; // In meters
}

message GeoLineString {
repeated GeoPoint points = 1; // Ordered sequence of GeoPoints representing the line
}

// For a valid GeoPolygon, both the exterior and interior GeoLineStrings must consist of a minimum of 4 points.
// Additionally, the first and last points of each GeoLineString must be the same.
message GeoPolygon {
// Ordered list of coordinates representing the vertices of a polygon.
// The minimum size is 4, and the first coordinate and the last coordinate
// should be the same to form a closed polygon.
repeated GeoPoint points = 1;
GeoLineString exterior = 1; // The exterior line bounds the surface
repeated GeoLineString interiors = 2; // Interior lines (if present) bound holes within the surface
}

message ValuesCount {
Expand Down
2 changes: 1 addition & 1 deletion proto/points_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ service Points {
*/
rpc SearchGroups (SearchPointGroups) returns (SearchGroupsResponse) {}
/*
Iterate over all or filtered points points
Iterate over all or filtered points
*/
rpc Scroll (ScrollPoints) returns (ScrollResponse) {}
/*
Expand Down
26 changes: 24 additions & 2 deletions src/filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use crate::qdrant::condition::ConditionOneOf;
use crate::qdrant::points_selector::PointsSelectorOneOf;
use crate::qdrant::r#match::MatchValue;
use crate::qdrant::{
Condition, FieldCondition, Filter, GeoBoundingBox, GeoRadius, HasIdCondition, IsEmptyCondition,
IsNullCondition, NestedCondition, PointId, PointsSelector, Range, ValuesCount,
Condition, FieldCondition, Filter, GeoBoundingBox, GeoPolygon, GeoRadius, HasIdCondition,
IsEmptyCondition, IsNullCondition, NestedCondition, PointId, PointsSelector, Range,
ValuesCount,
};

impl From<Filter> for PointsSelector {
Expand Down Expand Up @@ -246,6 +247,27 @@ impl qdrant::Condition {
}
}

/// create a Condition that checks geo fields against a geo polygons
///
/// # Examples:
///
/// ```
/// use qdrant_client::qdrant::{GeoLineString, GeoPoint, GeoPolygon};
/// let polygon = GeoPolygon {
/// exterior: Some(GeoLineString { points: vec![GeoPoint { lon: 42., lat: 42. }]}),
/// interiors: vec![],
/// };
/// qdrant_client::qdrant::Condition::geo_polygon("location", polygon);
pub fn geo_polygon(field: impl Into<String>, geo_polygon: GeoPolygon) -> Self {
Self {
condition_one_of: Some(ConditionOneOf::Field(qdrant::FieldCondition {
key: field.into(),
geo_polygon: Some(geo_polygon),
..Default::default()
})),
}
}

/// create a Condition that checks count of values in a field
///
/// # Examples:
Expand Down
91 changes: 80 additions & 11 deletions src/qdrant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,9 @@ pub struct CollectionParams {
/// How many replicas should apply the operation for us to consider it successful
#[prost(uint32, optional, tag = "7")]
pub write_consistency_factor: ::core::option::Option<u32>,
/// Fan-out every read request to these many additional remote nodes (and return first available response)
#[prost(uint32, optional, tag = "8")]
pub read_fan_out_factor: ::core::option::Option<u32>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand All @@ -415,6 +418,9 @@ pub struct CollectionParamsDiff {
/// If true - point's payload will not be stored in memory
#[prost(bool, optional, tag = "3")]
pub on_disk_payload: ::core::option::Option<bool>,
/// Fan-out every read request to these many additional remote nodes (and return first available response)
#[prost(uint32, optional, tag = "4")]
pub read_fan_out_factor: ::core::option::Option<u32>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand Down Expand Up @@ -2408,7 +2414,7 @@ pub struct QuantizationSearchParams {
#[prost(bool, optional, tag = "1")]
pub ignore: ::core::option::Option<bool>,
///
/// If true, use original vectors to re-score top-k results. Default is true.
/// If true, use original vectors to re-score top-k results. If ignored, qdrant decides automatically does rescore enabled or not.
#[prost(bool, optional, tag = "2")]
pub rescore: ::core::option::Option<bool>,
///
Expand Down Expand Up @@ -2589,10 +2595,10 @@ pub struct RecommendPoints {
/// name of the collection
#[prost(string, tag = "1")]
pub collection_name: ::prost::alloc::string::String,
/// Look for vectors closest to those
/// Look for vectors closest to the vectors from these points
#[prost(message, repeated, tag = "2")]
pub positive: ::prost::alloc::vec::Vec<PointId>,
/// Try to avoid vectors like this
/// Try to avoid vectors like the vector from these points
#[prost(message, repeated, tag = "3")]
pub negative: ::prost::alloc::vec::Vec<PointId>,
/// Filter conditions - return only those points that satisfy the specified conditions
Expand Down Expand Up @@ -2625,6 +2631,15 @@ pub struct RecommendPoints {
/// Options for specifying read consistency guarantees
#[prost(message, optional, tag = "14")]
pub read_consistency: ::core::option::Option<ReadConsistency>,
/// How to use the example vectors to find the results
#[prost(enumeration = "RecommendStrategy", optional, tag = "16")]
pub strategy: ::core::option::Option<i32>,
/// Look for vectors closest to those
#[prost(message, repeated, tag = "17")]
pub positive_vectors: ::prost::alloc::vec::Vec<Vector>,
/// Try to avoid vectors like this
#[prost(message, repeated, tag = "18")]
pub negative_vectors: ::prost::alloc::vec::Vec<Vector>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand All @@ -2644,10 +2659,10 @@ pub struct RecommendPointGroups {
/// Name of the collection
#[prost(string, tag = "1")]
pub collection_name: ::prost::alloc::string::String,
/// Look for vectors closest to those
/// Look for vectors closest to the vectors from these points
#[prost(message, repeated, tag = "2")]
pub positive: ::prost::alloc::vec::Vec<PointId>,
/// Try to avoid vectors like this
/// Try to avoid vectors like the vector from these points
#[prost(message, repeated, tag = "3")]
pub negative: ::prost::alloc::vec::Vec<PointId>,
/// Filter conditions - return only those points that satisfy the specified conditions
Expand Down Expand Up @@ -2686,6 +2701,15 @@ pub struct RecommendPointGroups {
/// Options for specifying how to use the group id to lookup points in another collection
#[prost(message, optional, tag = "15")]
pub with_lookup: ::core::option::Option<WithLookup>,
/// How to use the example vectors to find the results
#[prost(enumeration = "RecommendStrategy", optional, tag = "17")]
pub strategy: ::core::option::Option<i32>,
/// Look for vectors closest to those
#[prost(message, repeated, tag = "18")]
pub positive_vectors: ::prost::alloc::vec::Vec<Vector>,
/// Try to avoid vectors like this
#[prost(message, repeated, tag = "19")]
pub negative_vectors: ::prost::alloc::vec::Vec<Vector>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand Down Expand Up @@ -3072,6 +3096,9 @@ pub struct FieldCondition {
/// Check number of values for a specific field
#[prost(message, optional, tag = "6")]
pub values_count: ::core::option::Option<ValuesCount>,
/// Check if geo point is within a given polygon
#[prost(message, optional, tag = "7")]
pub geo_polygon: ::core::option::Option<GeoPolygon>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand Down Expand Up @@ -3156,13 +3183,23 @@ pub struct GeoRadius {
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GeoPolygon {
/// Ordered list of coordinates representing the vertices of a polygon.
/// The minimum size is 4, and the first coordinate and the last coordinate
/// should be the same to form a closed polygon.
pub struct GeoLineString {
/// Ordered sequence of GeoPoints representing the line
#[prost(message, repeated, tag = "1")]
pub points: ::prost::alloc::vec::Vec<GeoPoint>,
}
/// For a valid GeoPolygon, both the exterior and interior GeoLineStrings must consist of a minimum of 4 points.
/// Additionally, the first and last points of each GeoLineString must be the same.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GeoPolygon {
/// The exterior line bounds the surface
#[prost(message, optional, tag = "1")]
pub exterior: ::core::option::Option<GeoLineString>,
/// Interior lines (if present) bound holes within the surface
#[prost(message, repeated, tag = "2")]
pub interiors: ::prost::alloc::vec::Vec<GeoLineString>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ValuesCount {
Expand Down Expand Up @@ -3320,6 +3357,38 @@ impl FieldType {
}
}
}
/// How to use positive and negative vectors to find the results, default is `AverageVector`:
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum RecommendStrategy {
/// Average positive and negative vectors and create a single query with the formula
/// `query = avg_pos + avg_pos - avg_neg`. Then performs normal search.
AverageVector = 0,
/// Uses custom search objective. Each candidate is compared against all
/// examples, its score is then chosen from the `max(max_pos_score, max_neg_score)`.
/// If the `max_neg_score` is chosen then it is squared and negated.
BestScore = 1,
}
impl RecommendStrategy {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
RecommendStrategy::AverageVector => "AverageVector",
RecommendStrategy::BestScore => "BestScore",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"AverageVector" => Some(Self::AverageVector),
"BestScore" => Some(Self::BestScore),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum UpdateStatus {
Expand Down Expand Up @@ -3793,7 +3862,7 @@ pub mod points_client {
self.inner.unary(req, path, codec).await
}
///
/// Iterate over all or filtered points points
/// Iterate over all or filtered points
pub async fn scroll(
&mut self,
request: impl tonic::IntoRequest<super::ScrollPoints>,
Expand Down Expand Up @@ -4068,7 +4137,7 @@ pub mod points_server {
tonic::Status,
>;
///
/// Iterate over all or filtered points points
/// Iterate over all or filtered points
async fn scroll(
&self,
request: tonic::Request<super::ScrollPoints>,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function stop_docker()
# Ensure current path is project root
cd "$(dirname "$0")/../"

QDRANT_VERSION='v1.5.0'
QDRANT_VERSION='v1.6.0'

QDRANT_HOST='localhost:6333'

Expand Down
Loading

0 comments on commit 95212d1

Please sign in to comment.