From ee28cac1592e799e4539feffa235c60f0ff030db Mon Sep 17 00:00:00 2001 From: jojii Date: Wed, 7 Aug 2024 12:28:01 +0200 Subject: [PATCH] update index params --- proto/collections.proto | 7 ++-- proto/points.proto | 11 +++++ src/qdrant.rs | 49 ++++++++++++++++++++--- src/qdrant_client/conversions/payloads.rs | 15 ++++++- tests/protos.rs | 14 +++++-- 5 files changed, 83 insertions(+), 13 deletions(-) diff --git a/proto/collections.proto b/proto/collections.proto index ba4b519..8049806 100644 --- a/proto/collections.proto +++ b/proto/collections.proto @@ -394,13 +394,13 @@ message KeywordIndexParams { message IntegerIndexParams { bool lookup = 1; // If true - support direct lookups. bool range = 2; // If true - support ranges filters. - optional bool is_tenant = 3; // If true - used for tenant optimization. + optional bool is_principal = 3; // If true - use this key to organize storage of the collection data. This option assumes that this key will be used in majority of filtered requests. optional bool on_disk = 4; // If true - store index on disk. } message FloatIndexParams { optional bool on_disk = 1; // If true - store index on disk. - optional bool is_tenant = 2; // If true - used for tenant optimization. + optional bool is_principal = 2; // If true - use this key to organize storage of the collection data. This option assumes that this key will be used in majority of filtered requests. } message GeoIndexParams { @@ -418,11 +418,12 @@ message BoolIndexParams { message DatetimeIndexParams { optional bool on_disk = 1; // If true - store index on disk. - optional bool is_tenant = 2; // If true - used for tenant optimization. + optional bool is_principal = 2; // If true - use this key to organize storage of the collection data. This option assumes that this key will be used in majority of filtered requests. } message UuidIndexParams { optional bool is_tenant = 1; // If true - used for tenant optimization. + optional bool on_disk = 2; // If true - store index on disk. } message PayloadIndexParams { diff --git a/proto/points.proto b/proto/points.proto index 8853b3e..1da3887 100644 --- a/proto/points.proto +++ b/proto/points.proto @@ -586,6 +586,17 @@ message QueryPointGroups { optional ShardKeySelector shard_key_selector = 17; // Specify in which shards to look for the points, if not specified - look in all shards } +message FacetValue { + oneof variant { + string string_value = 1; // String value from the facet + } +} + +message FacetValueHit { + FacetValue value = 1; // Value from the facet + uint64 count = 2; // Number of points with this value +} + message PointsUpdateOperation { message PointStructList { repeated PointStruct points = 1; diff --git a/src/qdrant.rs b/src/qdrant.rs index 2e06920..fec12a4 100644 --- a/src/qdrant.rs +++ b/src/qdrant.rs @@ -739,10 +739,10 @@ pub struct IntegerIndexParams { #[prost(bool, tag = "2")] #[builder(default, setter(into, strip_option), field(vis = "pub(crate)"))] pub range: bool, - /// If true - used for tenant optimization. + /// If true - use this key to organize storage of the collection data. This option assumes that this key will be used in majority of filtered requests. #[prost(bool, optional, tag = "3")] #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] - pub is_tenant: ::core::option::Option, + pub is_principal: ::core::option::Option, /// If true - store index on disk. #[prost(bool, optional, tag = "4")] #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] @@ -760,10 +760,10 @@ pub struct FloatIndexParams { #[prost(bool, optional, tag = "1")] #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub on_disk: ::core::option::Option, - /// If true - used for tenant optimization. + /// If true - use this key to organize storage of the collection data. This option assumes that this key will be used in majority of filtered requests. #[prost(bool, optional, tag = "2")] #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] - pub is_tenant: ::core::option::Option, + pub is_principal: ::core::option::Option, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] @@ -809,17 +809,27 @@ pub struct DatetimeIndexParams { #[prost(bool, optional, tag = "1")] #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub on_disk: ::core::option::Option, - /// If true - used for tenant optimization. + /// If true - use this key to organize storage of the collection data. This option assumes that this key will be used in majority of filtered requests. #[prost(bool, optional, tag = "2")] #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] - pub is_tenant: ::core::option::Option, + pub is_principal: ::core::option::Option, } +#[derive(derive_builder::Builder)] +#[builder( + build_fn(private, error = "std::convert::Infallible", name = "build_inner"), + pattern = "owned" +)] #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] pub struct UuidIndexParams { /// If true - used for tenant optimization. #[prost(bool, optional, tag = "1")] + #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] pub is_tenant: ::core::option::Option, + /// If true - store index on disk. + #[prost(bool, optional, tag = "2")] + #[builder(default, setter(strip_option), field(vis = "pub(crate)"))] + pub on_disk: ::core::option::Option, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, Copy, PartialEq, ::prost::Message)] @@ -4920,6 +4930,32 @@ pub struct QueryPointGroups { } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] +pub struct FacetValue { + #[prost(oneof = "facet_value::Variant", tags = "1")] + pub variant: ::core::option::Option, +} +/// Nested message and enum types in `FacetValue`. +pub mod facet_value { + #[allow(clippy::derive_partial_eq_without_eq)] + #[derive(Clone, PartialEq, ::prost::Oneof)] + pub enum Variant { + /// String value from the facet + #[prost(string, tag = "1")] + StringValue(::prost::alloc::string::String), + } +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct FacetValueHit { + /// Value from the facet + #[prost(message, optional, tag = "1")] + pub value: ::core::option::Option, + /// Number of points with this value + #[prost(uint64, tag = "2")] + pub count: u64, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] pub struct PointsUpdateOperation { #[prost( oneof = "points_update_operation::Operation", @@ -9154,6 +9190,7 @@ builder_type_conversions!(TextIndexParams, TextIndexParamsBuilder, true); builder_type_conversions!(IntegerIndexParams, IntegerIndexParamsBuilder, true); builder_type_conversions!(KeywordIndexParams, KeywordIndexParamsBuilder); builder_type_conversions!(DatetimeIndexParams, DatetimeIndexParamsBuilder); +builder_type_conversions!(UuidIndexParams, UuidIndexParamsBuilder); builder_type_conversions!(FloatIndexParams, FloatIndexParamsBuilder); builder_type_conversions!(CreateAlias, CreateAliasBuilder, true); builder_type_conversions!(RenameAlias, RenameAliasBuilder, true); diff --git a/src/qdrant_client/conversions/payloads.rs b/src/qdrant_client/conversions/payloads.rs index d2105cb..1913a80 100644 --- a/src/qdrant_client/conversions/payloads.rs +++ b/src/qdrant_client/conversions/payloads.rs @@ -2,7 +2,8 @@ use crate::qdrant::payload_index_params::IndexParams; use crate::qdrant::{ DatetimeIndexParams, DatetimeIndexParamsBuilder, FloatIndexParams, FloatIndexParamsBuilder, IntegerIndexParams, IntegerIndexParamsBuilder, KeywordIndexParams, KeywordIndexParamsBuilder, - PayloadIndexParams, TextIndexParams, TextIndexParamsBuilder, + PayloadIndexParams, TextIndexParams, TextIndexParamsBuilder, UuidIndexParams, + UuidIndexParamsBuilder, }; impl From for PayloadIndexParams { @@ -88,3 +89,15 @@ impl From for IndexParams { Self::DatetimeIndexParams(value.build()) } } + +impl From for IndexParams { + fn from(value: UuidIndexParams) -> Self { + Self::UuidIndexParams(value) + } +} + +impl From for IndexParams { + fn from(value: UuidIndexParamsBuilder) -> Self { + Self::UuidIndexParams(value.build()) + } +} diff --git a/tests/protos.rs b/tests/protos.rs index c234f04..194d30a 100644 --- a/tests/protos.rs +++ b/tests/protos.rs @@ -712,17 +712,20 @@ fn configure_builder(builder: Builder) -> Builder { // IntegerIndexParams ("IntegerIndexParams.lookup", DEFAULT_OPTION_INTO), ("IntegerIndexParams.range", DEFAULT_OPTION_INTO), - ("IntegerIndexParams.is_tenant", DEFAULT_OPTION), + ("IntegerIndexParams.is_principal", DEFAULT_OPTION), ("IntegerIndexParams.on_disk", DEFAULT_OPTION), // KeywordIndexParams ("KeywordIndexParams.is_tenant", DEFAULT_OPTION), ("KeywordIndexParams.on_disk", DEFAULT_OPTION), // FloatIndexParams - ("FloatIndexParams.is_tenant", DEFAULT_OPTION), + ("FloatIndexParams.is_principal", DEFAULT_OPTION), ("FloatIndexParams.on_disk", DEFAULT_OPTION), // DatetimeIndexParams - ("DatetimeIndexParams.is_tenant", DEFAULT_OPTION), + ("DatetimeIndexParams.is_principal", DEFAULT_OPTION), ("DatetimeIndexParams.on_disk", DEFAULT_OPTION), + // UuidIndexParams + ("UuidIndexParams.is_tenant", DEFAULT_OPTION), + ("UuidIndexParams.on_disk", DEFAULT_OPTION), // RecommendInput ("RecommendInput.positive", DEFAULT_OPTION_INTO), ("RecommendInput.negative", DEFAULT_OPTION_INTO), @@ -1047,6 +1050,11 @@ fn builder_derive_options() -> &'static [BuildDeriveOptions] { DEFAULT_BUILDER_DERIVE_OPTIONS, MacroConfig::DefaultImpl, ), + ( + "UuidIndexParams", + DEFAULT_BUILDER_DERIVE_OPTIONS, + MacroConfig::DefaultImpl, + ), ( "FloatIndexParams", DEFAULT_BUILDER_DERIVE_OPTIONS,