Skip to content

Commit

Permalink
Update IndexParams
Browse files Browse the repository at this point in the history
  • Loading branch information
JojiiOfficial committed Jul 29, 2024
1 parent 91039ca commit 93f7806
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 16 deletions.
12 changes: 12 additions & 0 deletions proto/collections.proto
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ enum PayloadSchemaType {
Text = 5;
Bool = 6;
Datetime = 7;
Uuid = 8;
}

enum QuantizationType {
Expand Down Expand Up @@ -387,15 +388,19 @@ enum TokenizerType {

message KeywordIndexParams {
optional bool is_tenant = 3; // If true - used for tenant optimization.
optional bool on_disk = 4; // If true - store index on disk.
}

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 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.
}

message GeoIndexParams {
Expand All @@ -412,6 +417,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.
}

message UuidIndexParams {
optional bool is_tenant = 1; // If true - used for tenant optimization.
}

message PayloadIndexParams {
Expand All @@ -423,6 +434,7 @@ message PayloadIndexParams {
TextIndexParams text_index_params = 1; // Parameters for text index
BoolIndexParams bool_index_params = 6; // Parameters for bool index
DatetimeIndexParams datetime_index_params = 7; // Parameters for datetime index
UuidIndexParams uuid_index_params = 8; // Parameters for uuid index
}
}

Expand Down
21 changes: 11 additions & 10 deletions proto/points.proto
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ enum FieldType {
FieldTypeText = 4;
FieldTypeBool = 5;
FieldTypeDatetime = 6;
FieldTypeUuid = 7;
}

message CreateFieldIndexCollection {
Expand Down Expand Up @@ -266,7 +267,7 @@ message SearchParams {
optional bool exact = 2;

/*
If set to true, search will ignore quantized vector data
If set to true, search will ignore quantized vector data
*/
optional QuantizationSearchParams quantization = 3;
/*
Expand Down Expand Up @@ -363,12 +364,12 @@ message ScrollPoints {

// 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
// 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)`.
// 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;
}
Expand Down Expand Up @@ -434,7 +435,7 @@ message RecommendPointGroups {
message TargetVector {
oneof target {
VectorExample single = 1;

// leaving extensibility for possibly adding multi-target
}
}
Expand Down Expand Up @@ -514,7 +515,7 @@ enum Fusion {
///
/// * `random` - Random sampling
enum Sample {
RANDOM = 0;
Random = 0;
}

message Query {
Expand Down Expand Up @@ -698,7 +699,7 @@ message GroupId {

message PointGroup {
GroupId id = 1; // Group id
repeated ScoredPoint hits = 2; // Points in the group
repeated ScoredPoint hits = 2; // Points in the group
RetrievedPoint lookup = 3; // Point(s) from the lookup collection that matches the group id
}

Expand Down Expand Up @@ -807,12 +808,12 @@ message Filter {
repeated Condition should = 1; // At least one of those conditions should match
repeated Condition must = 2; // All conditions must match
repeated Condition must_not = 3; // All conditions must NOT match
optional MinShould min_should = 4; // At least minimum amount of given conditions should match
optional MinShould min_should = 4; // At least minimum amount of given conditions should match
}

message MinShould {
repeated Condition conditions = 1;
uint64 min_count = 2;
repeated Condition conditions = 1;
uint64 min_count = 2;
}

message Condition {
Expand Down
67 changes: 62 additions & 5 deletions src/qdrant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,10 @@ pub struct KeywordIndexParams {
#[prost(bool, optional, tag = "3")]
#[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 = "4")]
#[builder(default, setter(strip_option), field(vis = "pub(crate)"))]
pub on_disk: ::core::option::Option<bool>,
}
#[derive(derive_builder::Builder)]
#[builder(
Expand All @@ -739,10 +743,28 @@ pub struct IntegerIndexParams {
#[prost(bool, optional, tag = "3")]
#[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 = "4")]
#[builder(default, setter(strip_option), field(vis = "pub(crate)"))]
pub on_disk: ::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 FloatIndexParams {}
pub struct FloatIndexParams {
/// If true - store index on disk.
#[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.
#[prost(bool, optional, tag = "2")]
#[builder(default, setter(strip_option), field(vis = "pub(crate)"))]
pub is_tenant: ::core::option::Option<bool>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct GeoIndexParams {}
Expand Down Expand Up @@ -775,13 +797,37 @@ pub struct TextIndexParams {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct BoolIndexParams {}
#[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 DatetimeIndexParams {
/// If true - store index on disk.
#[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.
#[prost(bool, optional, tag = "2")]
#[builder(default, setter(strip_option), field(vis = "pub(crate)"))]
pub is_tenant: ::core::option::Option<bool>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct DatetimeIndexParams {}
pub struct UuidIndexParams {
/// If true - used for tenant optimization.
#[prost(bool, optional, tag = "1")]
pub is_tenant: ::core::option::Option<bool>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct PayloadIndexParams {
#[prost(oneof = "payload_index_params::IndexParams", tags = "3, 2, 4, 5, 1, 6, 7")]
#[prost(
oneof = "payload_index_params::IndexParams",
tags = "3, 2, 4, 5, 1, 6, 7, 8"
)]
pub index_params: ::core::option::Option<payload_index_params::IndexParams>,
}
/// Nested message and enum types in `PayloadIndexParams`.
Expand Down Expand Up @@ -810,6 +856,9 @@ pub mod payload_index_params {
/// Parameters for datetime index
#[prost(message, tag = "7")]
DatetimeIndexParams(super::DatetimeIndexParams),
/// Parameters for uuid index
#[prost(message, tag = "8")]
UuidIndexParams(super::UuidIndexParams),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
Expand Down Expand Up @@ -1474,6 +1523,7 @@ pub enum PayloadSchemaType {
Text = 5,
Bool = 6,
Datetime = 7,
Uuid = 8,
}
impl PayloadSchemaType {
/// String value of the enum field names used in the ProtoBuf definition.
Expand All @@ -1490,6 +1540,7 @@ impl PayloadSchemaType {
PayloadSchemaType::Text => "Text",
PayloadSchemaType::Bool => "Bool",
PayloadSchemaType::Datetime => "Datetime",
PayloadSchemaType::Uuid => "Uuid",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
Expand All @@ -1503,6 +1554,7 @@ impl PayloadSchemaType {
"Text" => Some(Self::Text),
"Bool" => Some(Self::Bool),
"Datetime" => Some(Self::Datetime),
"Uuid" => Some(Self::Uuid),
_ => None,
}
}
Expand Down Expand Up @@ -5637,6 +5689,7 @@ pub enum FieldType {
Text = 4,
Bool = 5,
Datetime = 6,
Uuid = 7,
}
impl FieldType {
/// String value of the enum field names used in the ProtoBuf definition.
Expand All @@ -5652,6 +5705,7 @@ impl FieldType {
FieldType::Text => "FieldTypeText",
FieldType::Bool => "FieldTypeBool",
FieldType::Datetime => "FieldTypeDatetime",
FieldType::Uuid => "FieldTypeUuid",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
Expand All @@ -5664,6 +5718,7 @@ impl FieldType {
"FieldTypeText" => Some(Self::Text),
"FieldTypeBool" => Some(Self::Bool),
"FieldTypeDatetime" => Some(Self::Datetime),
"FieldTypeUuid" => Some(Self::Uuid),
_ => None,
}
}
Expand Down Expand Up @@ -5771,13 +5826,13 @@ impl Sample {
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Sample::Random => "RANDOM",
Sample::Random => "Random",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"RANDOM" => Some(Self::Random),
"Random" => Some(Self::Random),
_ => None,
}
}
Expand Down Expand Up @@ -9092,6 +9147,8 @@ builder_type_conversions!(ContextExamplePair, ContextExamplePairBuilder);
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!(FloatIndexParams, FloatIndexParamsBuilder);
builder_type_conversions!(CreateAlias, CreateAliasBuilder, true);
builder_type_conversions!(RenameAlias, RenameAliasBuilder, true);
builder_type_conversions!(DeleteSnapshotRequest, DeleteSnapshotRequestBuilder, true);
Expand Down
18 changes: 18 additions & 0 deletions tests/protos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,8 +713,16 @@ fn configure_builder(builder: Builder) -> Builder {
("IntegerIndexParams.lookup", DEFAULT_OPTION_INTO),
("IntegerIndexParams.range", DEFAULT_OPTION_INTO),
("IntegerIndexParams.is_tenant", 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.on_disk", DEFAULT_OPTION),
// DatetimeIndexParams
("DatetimeIndexParams.is_tenant", DEFAULT_OPTION),
("DatetimeIndexParams.on_disk", DEFAULT_OPTION),
// RecommendInput
("RecommendInput.positive", DEFAULT_OPTION_INTO),
("RecommendInput.negative", DEFAULT_OPTION_INTO),
Expand Down Expand Up @@ -1034,6 +1042,16 @@ fn builder_derive_options() -> &'static [BuildDeriveOptions] {
DEFAULT_BUILDER_DERIVE_OPTIONS,
MacroConfig::DefaultImpl,
),
(
"DatetimeIndexParams",
DEFAULT_BUILDER_DERIVE_OPTIONS,
MacroConfig::DefaultImpl,
),
(
"FloatIndexParams",
DEFAULT_BUILDER_DERIVE_OPTIONS,
MacroConfig::DefaultImpl,
),
(
"CreateAlias",
NO_DEFAULT_BUILDER_DERIVE_OPTIONS,
Expand Down
2 changes: 1 addition & 1 deletion tools/sync_proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PROJECT_ROOT="$(pwd)/$(dirname "$0")/../"

cd $(mktemp -d)

git clone --sparse --filter=blob:none --depth=1 -b dev git@github.com:qdrant/qdrant.git
git clone --sparse --filter=blob:none --depth=1 -b extend_tenant_api git@github.com:qdrant/qdrant.git
cd qdrant
git sparse-checkout add lib/api/src/grpc/proto

Expand Down

0 comments on commit 93f7806

Please sign in to comment.