Skip to content

Update 1.1.1 #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "qdrant-client"
version = "1.1.0"
version = "1.1.1"
edition = "2021"
authors = ["Qdrant Team <[email protected]>"]
description = "Rust client for Qdrant Vector Search Engine"
Expand All @@ -17,14 +17,14 @@ tonic = { version = "0.8.3", features = ["tls", "tls-roots"] }
prost = "0.11.8"
prost-types = "0.11.8"
anyhow = "1"
reqwest = { version = "0.11.14", optional = true, features = ["stream"] }
futures-util = { version = "0.3.27", optional = true }
reqwest = { version = "0.11.16", optional = true, features = ["stream"] }
futures-util = { version = "0.3.28", optional = true }

[build-dependencies]
tonic-build = { version = "0.8.4", features = ["prost"] }

[dev-dependencies]
tokio = { version = "1.26.0", features = ["rt-multi-thread"] }
tokio = { version = "1.27.0", features = ["rt-multi-thread"] }

[features]
default = ["download_snapshots"]
Expand Down
2 changes: 2 additions & 0 deletions examples/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ async fn main() -> Result<()> {
config: Some(Config::Params(VectorParams {
size: 10,
distance: Distance::Cosine.into(),
hnsw_config: None,
quantization_config: None,
})),
}),
..Default::default()
Expand Down
24 changes: 13 additions & 11 deletions proto/collections.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ package qdrant;
message VectorParams {
uint64 size = 1; // Size of the vectors
Distance distance = 2; // Distance function used for comparing vectors
optional HnswConfigDiff hnsw_config = 3; // Configuration of vector HNSW graph. If omitted - the collection configuration will be used
optional QuantizationConfig quantization_config = 4; // Configuration of vector quantization config. If omitted - the collection configuration will be used
}

message VectorParamsMap {
Expand Down Expand Up @@ -77,22 +79,22 @@ message HnswConfigDiff {
*/
optional uint64 m = 1;
/*
Number of neighbours to consider during the index building. Larger the value - more accurate the search, more time required to build index.
Number of neighbours to consider during the index building. Larger the value - more accurate the search, more time required to build the index.
*/
optional uint64 ef_construct = 2;
/*
Minimal size (in KiloBytes) of vectors for additional payload-based indexing.
If payload chunk is smaller than `full_scan_threshold` additional indexing won't be used -
If the payload chunk is smaller than `full_scan_threshold` additional indexing won't be used -
in this case full-scan search should be preferred by query planner and additional indexing is not required.
Note: 1Kb = 1 vector of size 256
Note: 1 Kb = 1 vector of size 256
*/
optional uint64 full_scan_threshold = 3;
/*
Number of parallel threads used for background index building. If 0 - auto selection.
*/
optional uint64 max_indexing_threads = 4;
/*
Store HNSW index on disk. If set to false, index will be stored in RAM.
Store HNSW index on disk. If set to false, the index will be stored in RAM.
*/
optional bool on_disk = 5;
/*
Expand All @@ -116,13 +118,13 @@ message OptimizersConfigDiff {
*/
optional uint64 vacuum_min_vector_number = 2;
/*
Target amount of segments optimizer will try to keep.
Target amount of segments the optimizer will try to keep.
Real amount of segments may vary depending on multiple parameters:

- Amount of stored points.
- Current write RPS.

It is recommended to select default number of segments as a factor of the number of search threads,
It is recommended to select the default number of segments as a factor of the number of search threads,
so that each segment would be handled evenly by one of the threads.
*/
optional uint64 default_segment_number = 3;
Expand All @@ -131,14 +133,14 @@ message OptimizersConfigDiff {
Large segments might require disproportionately long indexation times,
therefore it makes sense to limit the size of segments.

If indexation speed have more priority for your - make this parameter lower.
If indexation speed has more priority for you - make this parameter lower.
If search speed is more important - make this parameter higher.
Note: 1Kb = 1 vector of size 256
*/
optional uint64 max_segment_size = 4;
/*
Maximum size (in KiloBytes) of vectors to store in-memory per segment.
Segments larger than this threshold will be stored as read-only memmaped file.
Segments larger than this threshold will be stored as a read-only memmaped file.
To enable memmap storage, lower the threshold
Note: 1Kb = 1 vector of size 256
*/
Expand Down Expand Up @@ -185,7 +187,7 @@ message CreateCollection {
optional uint32 replication_factor = 11; // Number of replicas of each shard that network tries to maintain, default = 1
optional uint32 write_consistency_factor = 12; // How many replicas should apply the operation for us to consider it successful, default = 1
optional string init_from_collection = 13; // Specify name of the other collection to copy data from
optional QuantizationConfig quantization_config = 14;
optional QuantizationConfig quantization_config = 14; // Quantization configuration of vector
}

message UpdateCollection {
Expand Down Expand Up @@ -237,7 +239,7 @@ enum TokenizerType {

message TextIndexParams {
TokenizerType tokenizer = 1; // Tokenizer type
optional bool lowercase = 2; // If true - all tokens will be lowercased
optional bool lowercase = 2; // If true - all tokens will be lowercase
optional uint64 min_token_len = 3; // Minimal token length
optional uint64 max_token_len = 4; // Maximal token length
}
Expand Down Expand Up @@ -309,4 +311,4 @@ message AliasDescription {
message ListAliasesResponse {
repeated AliasDescription aliases = 1;
double time = 2; // Time spent to process
}
}
8 changes: 4 additions & 4 deletions proto/json_with_int.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ package qdrant;
// object. The details of that representation are described together
// with the proto support for the language.
//
// The JSON representation for `Struct` is JSON object.
// The JSON representation for `Struct` is a JSON object.
message Struct {
// Unordered map of dynamically typed values.
map<string, Value> fields = 1;
}

// `Value` represents a dynamically typed value which can be either
// null, a number, a string, a boolean, a recursive struct value, or a
// list of values. A producer of value is expected to set one of that
// list of values. A producer of value is expected to set one of those
// variants, absence of any variant indicates an error.
//
// The JSON representation for `Value` is JSON value.
// The JSON representation for `Value` is a JSON value.
message Value {
// The kind of value.
oneof kind {
Expand Down Expand Up @@ -54,7 +54,7 @@ enum NullValue {

// `ListValue` is a wrapper around a repeated field of values.
//
// The JSON representation for `ListValue` is JSON array.
// The JSON representation for `ListValue` is a JSON array.
message ListValue {
// Repeated field of dynamically typed values.
repeated Value values = 1;
Expand Down
7 changes: 6 additions & 1 deletion proto/points.proto
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,18 @@ message Condition {
IsEmptyCondition is_empty = 2;
HasIdCondition has_id = 3;
Filter filter = 4;
IsNullCondition is_null = 5;
}
}

message IsEmptyCondition {
string key = 1;
}

message IsNullCondition {
string key = 1;
}

message HasIdCondition {
repeated PointId has_id = 1;
}
Expand All @@ -365,7 +370,7 @@ message FieldCondition {
string key = 1;
Match match = 2; // Check if point has field with a given value
Range range = 3; // Check if points value lies in a given range
GeoBoundingBox geo_bounding_box = 4; // Check if points geo location lies in a given area
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
}
Expand Down
4 changes: 2 additions & 2 deletions proto/points_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "google/protobuf/struct.proto";

service Points {
/*
Perform insert + updates on points. If point with given ID already exists - it will be overwritten.
Perform insert + updates on points. If a point with a given ID already exists - it will be overwritten.
*/
rpc Upsert (UpsertPoints) returns (PointsOperationResponse) {}
/*
Expand Down Expand Up @@ -67,4 +67,4 @@ service Points {
Count points in collection with given filtering conditions
*/
rpc Count (CountPoints) returns (CountResponse) {}
}
}
44 changes: 34 additions & 10 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,24 @@ use crate::qdrant::snapshots_client::SnapshotsClient;
use crate::qdrant::value::Kind;
use crate::qdrant::vectors::VectorsOptions;
use crate::qdrant::with_payload_selector::SelectorOptions;
use crate::qdrant::{qdrant_client, with_vectors_selector, AliasOperations, ChangeAliases, ClearPayloadPoints, CollectionOperationResponse, Condition, CountPoints, CountResponse, CreateAlias, CreateCollection, CreateFieldIndexCollection, CreateFullSnapshotRequest, CreateSnapshotRequest, CreateSnapshotResponse, DeleteAlias, DeleteCollection, DeleteFieldIndexCollection, DeleteFullSnapshotRequest, DeletePayloadPoints, DeletePoints, DeleteSnapshotRequest, DeleteSnapshotResponse, FieldCondition, FieldType, Filter, GetCollectionInfoRequest, GetCollectionInfoResponse, GetPoints, GetResponse, HasIdCondition, HealthCheckReply, HealthCheckRequest, IsEmptyCondition, ListAliasesRequest, ListAliasesResponse, ListCollectionAliasesRequest, ListCollectionsRequest, ListCollectionsResponse, ListFullSnapshotsRequest, ListSnapshotsRequest, ListSnapshotsResponse, ListValue, NamedVectors, OptimizersConfigDiff, PayloadIncludeSelector, PayloadIndexParams, PointId, PointStruct, PointsIdsList, PointsOperationResponse, PointsSelector, RecommendBatchPoints, RecommendBatchResponse, RecommendPoints, RecommendResponse, RenameAlias, ScrollPoints, ScrollResponse, SearchBatchPoints, SearchBatchResponse, SearchPoints, SearchResponse, SetPayloadPoints, Struct, UpdateCollection, UpsertPoints, Value, Vector, Vectors, VectorsSelector, WithPayloadSelector, WithVectorsSelector, WriteOrdering, ReadConsistency};
use crate::qdrant::{
qdrant_client, with_vectors_selector, AliasOperations, ChangeAliases, ClearPayloadPoints,
CollectionOperationResponse, Condition, CountPoints, CountResponse, CreateAlias,
CreateCollection, CreateFieldIndexCollection, CreateFullSnapshotRequest, CreateSnapshotRequest,
CreateSnapshotResponse, DeleteAlias, DeleteCollection, DeleteFieldIndexCollection,
DeleteFullSnapshotRequest, DeletePayloadPoints, DeletePoints, DeleteSnapshotRequest,
DeleteSnapshotResponse, FieldCondition, FieldType, Filter, GetCollectionInfoRequest,
GetCollectionInfoResponse, GetPoints, GetResponse, HasIdCondition, HealthCheckReply,
HealthCheckRequest, IsEmptyCondition, ListAliasesRequest, ListAliasesResponse,
ListCollectionAliasesRequest, ListCollectionsRequest, ListCollectionsResponse,
ListFullSnapshotsRequest, ListSnapshotsRequest, ListSnapshotsResponse, ListValue, NamedVectors,
OptimizersConfigDiff, PayloadIncludeSelector, PayloadIndexParams, PointId, PointStruct,
PointsIdsList, PointsOperationResponse, PointsSelector, ReadConsistency, RecommendBatchPoints,
RecommendBatchResponse, RecommendPoints, RecommendResponse, RenameAlias, ScrollPoints,
ScrollResponse, SearchBatchPoints, SearchBatchResponse, SearchPoints, SearchResponse,
SetPayloadPoints, Struct, UpdateCollection, UpsertPoints, Value, Vector, Vectors,
VectorsSelector, WithPayloadSelector, WithVectorsSelector, WriteOrdering,
};
use anyhow::{bail, Result};
use std::collections::HashMap;
use std::future::Future;
Expand All @@ -30,7 +47,10 @@ pub struct QdrantClientConfig {

impl QdrantClientConfig {
pub fn from_url(url: &str) -> Self {
QdrantClientConfig { uri: url.to_string(), ..Self::default() }
QdrantClientConfig {
uri: url.to_string(),
..Self::default()
}
}

pub fn set_api_key(&mut self, api_key: &str) {
Expand Down Expand Up @@ -499,7 +519,8 @@ impl QdrantClient {
points: Vec<PointStruct>,
ordering: Option<WriteOrdering>,
) -> Result<PointsOperationResponse> {
self._upsert_points(collection_name, &points, false, ordering).await
self._upsert_points(collection_name, &points, false, ordering)
.await
}

pub async fn upsert_points_blocking(
Expand All @@ -508,7 +529,8 @@ impl QdrantClient {
points: Vec<PointStruct>,
ordering: Option<WriteOrdering>,
) -> Result<PointsOperationResponse> {
self._upsert_points(collection_name, &points, true, ordering).await
self._upsert_points(collection_name, &points, true, ordering)
.await
}

#[inline]
Expand All @@ -517,7 +539,7 @@ impl QdrantClient {
collection_name: impl ToString,
points: &Vec<PointStruct>,
block: bool,
ordering: Option<WriteOrdering>
ordering: Option<WriteOrdering>,
) -> Result<PointsOperationResponse> {
let collection_name = collection_name.to_string();
let collection_name_ref = collection_name.as_str();
Expand Down Expand Up @@ -554,7 +576,7 @@ impl QdrantClient {
collection_name: impl ToString,
points: &PointsSelector,
payload: Payload,
ordering: Option<WriteOrdering>
ordering: Option<WriteOrdering>,
) -> Result<PointsOperationResponse> {
self._set_payload(collection_name, points, &payload, true, ordering)
.await
Expand Down Expand Up @@ -594,7 +616,7 @@ impl QdrantClient {
collection_name: impl ToString,
points: &PointsSelector,
payload: Payload,
ordering: Option<WriteOrdering>
ordering: Option<WriteOrdering>,
) -> Result<PointsOperationResponse> {
self._overwrite_payload(collection_name, points, &payload, false, ordering)
.await
Expand All @@ -618,7 +640,7 @@ impl QdrantClient {
points: &PointsSelector,
payload: &Payload,
block: bool,
ordering: Option<WriteOrdering>
ordering: Option<WriteOrdering>,
) -> Result<PointsOperationResponse> {
let collection_name = collection_name.to_string();
let collection_name_ref = collection_name.as_str();
Expand Down Expand Up @@ -800,7 +822,8 @@ impl QdrantClient {
points: &PointsSelector,
ordering: Option<WriteOrdering>,
) -> Result<PointsOperationResponse> {
self._delete_points(collection_name, false, points, ordering).await
self._delete_points(collection_name, false, points, ordering)
.await
}

pub async fn delete_points_blocking(
Expand All @@ -809,7 +832,8 @@ impl QdrantClient {
points: &PointsSelector,
ordering: Option<WriteOrdering>,
) -> Result<PointsOperationResponse> {
self._delete_points(collection_name, true, points, ordering).await
self._delete_points(collection_name, true, points, ordering)
.await
}

async fn _delete_points(
Expand Down
12 changes: 10 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ mod tests {
config: Some(Config::Params(VectorParams {
size: 10,
distance: Distance::Cosine.into(),
hnsw_config: None,
quantization_config: None,
})),
}),
..Default::default()
Expand Down Expand Up @@ -92,13 +94,19 @@ mod tests {
collection_name,
&vec![0.into()].into(),
vec!["sub_payload".to_string()],
None
None,
)
.await?;

// retrieve points
let points = client
.get_points(collection_name, &vec![0.into()], Some(true), Some(true), None)
.get_points(
collection_name,
&vec![0.into()],
Some(true),
Some(true),
None,
)
.await?;

assert_eq!(points.result.len(), 1);
Expand Down
Loading