Skip to content

Commit

Permalink
update index params (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
JojiiOfficial authored and agourlay committed Aug 12, 2024
1 parent aed9070 commit e9dbb02
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 13 deletions.
7 changes: 4 additions & 3 deletions proto/collections.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
11 changes: 11 additions & 0 deletions proto/points.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
49 changes: 43 additions & 6 deletions src/qdrant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>,
pub is_principal: ::core::option::Option<bool>,
/// If true - store index on disk.
#[prost(bool, optional, tag = "4")]
#[builder(default, setter(strip_option), field(vis = "pub(crate)"))]
Expand All @@ -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<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 = "2")]
#[builder(default, setter(strip_option), field(vis = "pub(crate)"))]
pub is_tenant: ::core::option::Option<bool>,
pub is_principal: ::core::option::Option<bool>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
Expand Down Expand Up @@ -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<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 = "2")]
#[builder(default, setter(strip_option), field(vis = "pub(crate)"))]
pub is_tenant: ::core::option::Option<bool>,
pub is_principal: ::core::option::Option<bool>,
}
#[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<bool>,
/// 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<bool>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
Expand Down Expand Up @@ -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<facet_value::Variant>,
}
/// 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<FacetValue>,
/// 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",
Expand Down Expand Up @@ -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);
Expand Down
15 changes: 14 additions & 1 deletion src/qdrant_client/conversions/payloads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IndexParams> for PayloadIndexParams {
Expand Down Expand Up @@ -88,3 +89,15 @@ impl From<DatetimeIndexParamsBuilder> for IndexParams {
Self::DatetimeIndexParams(value.build())
}
}

impl From<UuidIndexParams> for IndexParams {
fn from(value: UuidIndexParams) -> Self {
Self::UuidIndexParams(value)
}
}

impl From<UuidIndexParamsBuilder> for IndexParams {
fn from(value: UuidIndexParamsBuilder) -> Self {
Self::UuidIndexParams(value.build())
}
}
14 changes: 11 additions & 3 deletions tests/protos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit e9dbb02

Please sign in to comment.