Skip to content

Commit beb689f

Browse files
committed
improve docs and validation for StrictModeConfig
1 parent 95d94e3 commit beb689f

7 files changed

Lines changed: 90 additions & 55 deletions

File tree

docs/grpc/docs.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,25 +1578,25 @@ Note: 1kB = 1 vector of size 256. |
15781578

15791579
| Field | Type | Label | Description |
15801580
| ----- | ---- | ----- | ----------- |
1581-
| enabled | [bool](#bool) | optional | |
1582-
| max_query_limit | [uint32](#uint32) | optional | |
1583-
| max_timeout | [uint32](#uint32) | optional | |
1584-
| unindexed_filtering_retrieve | [bool](#bool) | optional | |
1585-
| unindexed_filtering_update | [bool](#bool) | optional | |
1586-
| search_max_hnsw_ef | [uint32](#uint32) | optional | |
1587-
| search_allow_exact | [bool](#bool) | optional | |
1588-
| search_max_oversampling | [float](#float) | optional | |
1589-
| upsert_max_batchsize | [uint64](#uint64) | optional | |
1581+
| enabled | [bool](#bool) | optional | Whether strict mode is enabled for a collection or not. |
1582+
| max_query_limit | [uint32](#uint32) | optional | Max allowed `limit` parameter for all APIs that don't have their own max limit. |
1583+
| max_timeout | [uint32](#uint32) | optional | Max allowed `timeout` parameter. |
1584+
| unindexed_filtering_retrieve | [bool](#bool) | optional | Allow usage of unindexed fields in retrieval based (e.g. search) filters. |
1585+
| unindexed_filtering_update | [bool](#bool) | optional | Allow usage of unindexed fields in filtered updates (e.g. delete by payload). |
1586+
| search_max_hnsw_ef | [uint32](#uint32) | optional | Max HNSW ef value allowed in search parameters. |
1587+
| search_allow_exact | [bool](#bool) | optional | Whether exact search is allowed. |
1588+
| search_max_oversampling | [float](#float) | optional | Max oversampling value allowed in search |
1589+
| upsert_max_batchsize | [uint64](#uint64) | optional | Max batchsize when upserting |
15901590
| max_collection_vector_size_bytes | [uint64](#uint64) | optional | |
15911591
| read_rate_limit | [uint32](#uint32) | optional | Max number of read operations per minute per replica |
15921592
| write_rate_limit | [uint32](#uint32) | optional | Max number of write operations per minute per replica |
1593-
| max_collection_payload_size_bytes | [uint64](#uint64) | optional | |
1594-
| filter_max_conditions | [uint64](#uint64) | optional | |
1595-
| condition_max_size | [uint64](#uint64) | optional | |
1596-
| multivector_config | [StrictModeMultivectorConfig](#qdrant-StrictModeMultivectorConfig) | optional | |
1597-
| sparse_config | [StrictModeSparseConfig](#qdrant-StrictModeSparseConfig) | optional | |
1598-
| max_points_count | [uint64](#uint64) | optional | |
1599-
| max_payload_index_count | [uint64](#uint64) | optional | |
1593+
| max_collection_payload_size_bytes | [uint64](#uint64) | optional | Max size of a collections vector storage in bytes, ignoring replicas. |
1594+
| filter_max_conditions | [uint64](#uint64) | optional | Max conditions a filter can have. |
1595+
| condition_max_size | [uint64](#uint64) | optional | Max size of a condition, eg. items in `MatchAny`. |
1596+
| multivector_config | [StrictModeMultivectorConfig](#qdrant-StrictModeMultivectorConfig) | optional | Multivector strict mode configuration |
1597+
| sparse_config | [StrictModeSparseConfig](#qdrant-StrictModeSparseConfig) | optional | Sparse vector strict mode configuration |
1598+
| max_points_count | [uint64](#uint64) | optional | Max number of points estimated in a collection |
1599+
| max_payload_index_count | [uint64](#uint64) | optional | Max number of payload indexes in a collection |
16001600

16011601

16021602

@@ -1611,7 +1611,7 @@ Note: 1kB = 1 vector of size 256. |
16111611

16121612
| Field | Type | Label | Description |
16131613
| ----- | ---- | ----- | ----------- |
1614-
| max_vectors | [uint64](#uint64) | optional | |
1614+
| max_vectors | [uint64](#uint64) | optional | Max number of vectors in a multivector |
16151615

16161616

16171617

@@ -1657,7 +1657,7 @@ Note: 1kB = 1 vector of size 256. |
16571657

16581658
| Field | Type | Label | Description |
16591659
| ----- | ---- | ----- | ----------- |
1660-
| max_length | [uint64](#uint64) | optional | |
1660+
| max_length | [uint64](#uint64) | optional | Max length of sparse vector |
16611661

16621662

16631663

docs/redoc/master/openapi.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7451,10 +7451,10 @@
74517451
]
74527452
},
74537453
"max_payload_index_count": {
7454-
"description": "Max number of payload index in a collection",
7454+
"description": "Max number of payload indexes in a collection",
74557455
"type": "integer",
74567456
"format": "uint",
7457-
"minimum": 1,
7457+
"minimum": 0,
74587458
"nullable": true
74597459
}
74607460
}
@@ -9909,14 +9909,14 @@
99099909
"nullable": true
99109910
},
99119911
"search_max_hnsw_ef": {
9912-
"description": "Max HNSW value allowed in search parameters.",
9912+
"description": "Max HNSW ef value allowed in search parameters.",
99139913
"type": "integer",
99149914
"format": "uint",
99159915
"minimum": 0,
99169916
"nullable": true
99179917
},
99189918
"search_allow_exact": {
9919-
"description": "Whether exact search is allowed or not.",
9919+
"description": "Whether exact search is allowed.",
99209920
"type": "boolean",
99219921
"nullable": true
99229922
},
@@ -9983,7 +9983,7 @@
99839983
"nullable": true
99849984
},
99859985
"multivector_config": {
9986-
"description": "Multivector configuration",
9986+
"description": "Multivector strict mode configuration",
99879987
"anyOf": [
99889988
{
99899989
"$ref": "#/components/schemas/StrictModeMultivectorConfig"
@@ -9994,7 +9994,7 @@
99949994
]
99959995
},
99969996
"sparse_config": {
9997-
"description": "Sparse vector configuration",
9997+
"description": "Sparse vector strict mode configuration",
99989998
"anyOf": [
99999999
{
1000010000
"$ref": "#/components/schemas/StrictModeSparseConfig"
@@ -10005,10 +10005,10 @@
1000510005
]
1000610006
},
1000710007
"max_payload_index_count": {
10008-
"description": "Max number of payload index in a collection",
10008+
"description": "Max number of payload indexes in a collection",
1000910009
"type": "integer",
1001010010
"format": "uint",
10011-
"minimum": 1,
10011+
"minimum": 0,
1001210012
"nullable": true
1001310013
}
1001410014
}

lib/api/build.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,15 @@ fn configure_validation(builder: Builder) -> Builder {
166166
("UpdateCollectionClusterSetupRequest.operation", ""),
167167
("StrictModeConfig.max_query_limit", "range(min = 1)"),
168168
("StrictModeConfig.max_timeout", "range(min = 1)"),
169+
("StrictModeConfig.max_points_count", "range(min = 1)"),
169170
("StrictModeConfig.read_rate_limit_per_minute", "range(min = 1)"),
170171
("StrictModeConfig.write_rate_limit_per_minute", "range(min = 1)"),
172+
("StrictModeConfig.multivector_config", ""),
173+
("StrictModeConfig.sparse_config", ""),
174+
("StrictModeSparseConfig.sparse_config", ""),
175+
("StrictModeSparse.max_length", "range(min = 1)"),
176+
("StrictModeMultivectorConfig.multivector_config", ""),
177+
("StrictModeMultivector.max_vectors", "range(min = 1)"),
171178
], &[
172179
"ListCollectionsRequest",
173180
"ListAliasesRequest",

lib/api/src/grpc/proto/collections.proto

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -355,42 +355,41 @@ enum ShardingMethod {
355355
}
356356

357357
message StrictModeConfig {
358-
optional bool enabled = 1;
359-
optional uint32 max_query_limit = 2;
360-
optional uint32 max_timeout = 3;
361-
optional bool unindexed_filtering_retrieve = 4;
362-
optional bool unindexed_filtering_update = 5;
363-
364-
optional uint32 search_max_hnsw_ef = 6;
365-
optional bool search_allow_exact = 7;
366-
optional float search_max_oversampling = 8;
367-
optional uint64 upsert_max_batchsize = 9;
358+
optional bool enabled = 1; // Whether strict mode is enabled for a collection or not.
359+
optional uint32 max_query_limit = 2; // Max allowed `limit` parameter for all APIs that don't have their own max limit.
360+
optional uint32 max_timeout = 3; // Max allowed `timeout` parameter.
361+
optional bool unindexed_filtering_retrieve = 4; // Allow usage of unindexed fields in retrieval based (e.g. search) filters.
362+
optional bool unindexed_filtering_update = 5; // Allow usage of unindexed fields in filtered updates (e.g. delete by payload).
363+
optional uint32 search_max_hnsw_ef = 6; // Max HNSW ef value allowed in search parameters.
364+
optional bool search_allow_exact = 7; // Whether exact search is allowed.
365+
optional float search_max_oversampling = 8; // Max oversampling value allowed in search
366+
optional uint64 upsert_max_batchsize = 9; // Max batchsize when upserting
368367
optional uint64 max_collection_vector_size_bytes = 10;
369368
optional uint32 read_rate_limit = 11; // Max number of read operations per minute per replica
370369
optional uint32 write_rate_limit = 12; // Max number of write operations per minute per replica
371-
optional uint64 max_collection_payload_size_bytes = 13;
372-
optional uint64 filter_max_conditions = 14;
373-
optional uint64 condition_max_size = 15;
374-
optional StrictModeMultivectorConfig multivector_config = 16;
375-
optional StrictModeSparseConfig sparse_config = 17;
376-
optional uint64 max_points_count = 18;
377-
optional uint64 max_payload_index_count = 19;
370+
optional uint64 max_collection_payload_size_bytes = 13; // Max size of a collections vector storage in bytes, ignoring replicas.
371+
optional uint64 filter_max_conditions = 14; // Max conditions a filter can have.
372+
optional uint64 condition_max_size = 15; // Max size of a condition, eg. items in `MatchAny`.
373+
optional StrictModeMultivectorConfig multivector_config = 16; // Multivector strict mode configuration
374+
optional StrictModeSparseConfig sparse_config = 17; // Sparse vector strict mode configuration
375+
optional uint64 max_points_count = 18; // Max number of points estimated in a collection
376+
optional uint64 max_payload_index_count = 19; // Max number of payload indexes in a collection
378377
}
379378

380379
message StrictModeSparseConfig {
381380
map<string, StrictModeSparse> sparse_config = 1;
382381
}
383382

384383
message StrictModeSparse {
385-
optional uint64 max_length = 10;
384+
optional uint64 max_length = 10; // Max length of sparse vector
386385
}
387386

388387
message StrictModeMultivectorConfig {
389388
map<string, StrictModeMultivector> multivector_config = 1;
390389
}
391390

392391
message StrictModeMultivector {
393-
optional uint64 max_vectors = 1;
392+
optional uint64 max_vectors = 1; // Max number of vectors in a multivector
394393
}
395394

396395
message CreateCollection {

lib/api/src/grpc/qdrant.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,24 +670,33 @@ pub mod quantization_config_diff {
670670
#[allow(clippy::derive_partial_eq_without_eq)]
671671
#[derive(Clone, PartialEq, ::prost::Message)]
672672
pub struct StrictModeConfig {
673+
/// Whether strict mode is enabled for a collection or not.
673674
#[prost(bool, optional, tag = "1")]
674675
pub enabled: ::core::option::Option<bool>,
676+
/// Max allowed `limit` parameter for all APIs that don't have their own max limit.
675677
#[prost(uint32, optional, tag = "2")]
676678
#[validate(range(min = 1))]
677679
pub max_query_limit: ::core::option::Option<u32>,
680+
/// Max allowed `timeout` parameter.
678681
#[prost(uint32, optional, tag = "3")]
679682
#[validate(range(min = 1))]
680683
pub max_timeout: ::core::option::Option<u32>,
684+
/// Allow usage of unindexed fields in retrieval based (e.g. search) filters.
681685
#[prost(bool, optional, tag = "4")]
682686
pub unindexed_filtering_retrieve: ::core::option::Option<bool>,
687+
/// Allow usage of unindexed fields in filtered updates (e.g. delete by payload).
683688
#[prost(bool, optional, tag = "5")]
684689
pub unindexed_filtering_update: ::core::option::Option<bool>,
690+
/// Max HNSW ef value allowed in search parameters.
685691
#[prost(uint32, optional, tag = "6")]
686692
pub search_max_hnsw_ef: ::core::option::Option<u32>,
693+
/// Whether exact search is allowed.
687694
#[prost(bool, optional, tag = "7")]
688695
pub search_allow_exact: ::core::option::Option<bool>,
696+
/// Max oversampling value allowed in search
689697
#[prost(float, optional, tag = "8")]
690698
pub search_max_oversampling: ::core::option::Option<f32>,
699+
/// Max batchsize when upserting
691700
#[prost(uint64, optional, tag = "9")]
692701
pub upsert_max_batchsize: ::core::option::Option<u64>,
693702
#[prost(uint64, optional, tag = "10")]
@@ -698,53 +707,73 @@ pub struct StrictModeConfig {
698707
/// Max number of write operations per minute per replica
699708
#[prost(uint32, optional, tag = "12")]
700709
pub write_rate_limit: ::core::option::Option<u32>,
710+
/// Max size of a collections vector storage in bytes, ignoring replicas.
701711
#[prost(uint64, optional, tag = "13")]
702712
pub max_collection_payload_size_bytes: ::core::option::Option<u64>,
713+
/// Max conditions a filter can have.
703714
#[prost(uint64, optional, tag = "14")]
704715
pub filter_max_conditions: ::core::option::Option<u64>,
716+
/// Max size of a condition, eg. items in `MatchAny`.
705717
#[prost(uint64, optional, tag = "15")]
706718
pub condition_max_size: ::core::option::Option<u64>,
719+
/// Multivector strict mode configuration
707720
#[prost(message, optional, tag = "16")]
721+
#[validate(nested)]
708722
pub multivector_config: ::core::option::Option<StrictModeMultivectorConfig>,
723+
/// Sparse vector strict mode configuration
709724
#[prost(message, optional, tag = "17")]
725+
#[validate(nested)]
710726
pub sparse_config: ::core::option::Option<StrictModeSparseConfig>,
727+
/// Max number of points estimated in a collection
711728
#[prost(uint64, optional, tag = "18")]
729+
#[validate(range(min = 1))]
712730
pub max_points_count: ::core::option::Option<u64>,
731+
/// Max number of payload indexes in a collection
713732
#[prost(uint64, optional, tag = "19")]
714733
pub max_payload_index_count: ::core::option::Option<u64>,
715734
}
735+
#[derive(validator::Validate)]
716736
#[derive(serde::Serialize)]
717737
#[allow(clippy::derive_partial_eq_without_eq)]
718738
#[derive(Clone, PartialEq, ::prost::Message)]
719739
pub struct StrictModeSparseConfig {
720740
#[prost(map = "string, message", tag = "1")]
741+
#[validate(nested)]
721742
pub sparse_config: ::std::collections::HashMap<
722743
::prost::alloc::string::String,
723744
StrictModeSparse,
724745
>,
725746
}
747+
#[derive(validator::Validate)]
726748
#[derive(serde::Serialize)]
727749
#[allow(clippy::derive_partial_eq_without_eq)]
728750
#[derive(Clone, PartialEq, ::prost::Message)]
729751
pub struct StrictModeSparse {
752+
/// Max length of sparse vector
730753
#[prost(uint64, optional, tag = "10")]
754+
#[validate(range(min = 1))]
731755
pub max_length: ::core::option::Option<u64>,
732756
}
757+
#[derive(validator::Validate)]
733758
#[derive(serde::Serialize)]
734759
#[allow(clippy::derive_partial_eq_without_eq)]
735760
#[derive(Clone, PartialEq, ::prost::Message)]
736761
pub struct StrictModeMultivectorConfig {
737762
#[prost(map = "string, message", tag = "1")]
763+
#[validate(nested)]
738764
pub multivector_config: ::std::collections::HashMap<
739765
::prost::alloc::string::String,
740766
StrictModeMultivector,
741767
>,
742768
}
769+
#[derive(validator::Validate)]
743770
#[derive(serde::Serialize)]
744771
#[allow(clippy::derive_partial_eq_without_eq)]
745772
#[derive(Clone, PartialEq, ::prost::Message)]
746773
pub struct StrictModeMultivector {
774+
/// Max number of vectors in a multivector
747775
#[prost(uint64, optional, tag = "1")]
776+
#[validate(range(min = 1))]
748777
pub max_vectors: ::core::option::Option<u64>,
749778
}
750779
#[derive(validator::Validate)]

lib/segment/src/types.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -970,11 +970,11 @@ pub struct StrictModeConfig {
970970
pub unindexed_filtering_update: Option<bool>,
971971

972972
// Search
973-
/// Max HNSW value allowed in search parameters.
973+
/// Max HNSW ef value allowed in search parameters.
974974
#[serde(skip_serializing_if = "Option::is_none")]
975975
pub search_max_hnsw_ef: Option<usize>,
976976

977-
/// Whether exact search is allowed or not.
977+
/// Whether exact search is allowed.
978978
#[serde(skip_serializing_if = "Option::is_none")]
979979
pub search_allow_exact: Option<bool>,
980980

@@ -1017,19 +1017,19 @@ pub struct StrictModeConfig {
10171017
#[serde(skip_serializing_if = "Option::is_none")]
10181018
pub condition_max_size: Option<usize>,
10191019

1020-
/// Multivector configuration
1020+
/// Multivector strict mode configuration
10211021
#[serde(skip_serializing_if = "Option::is_none")]
10221022
#[validate(nested)]
10231023
pub multivector_config: Option<StrictModeMultivectorConfig>,
10241024

1025-
/// Sparse vector configuration
1025+
/// Sparse vector strict mode configuration
10261026
#[serde(skip_serializing_if = "Option::is_none")]
10271027
#[validate(nested)]
10281028
pub sparse_config: Option<StrictModeSparseConfig>,
10291029

1030-
/// Max number of payload index in a collection
1030+
/// Max number of payload indexes in a collection
10311031
#[serde(skip_serializing_if = "Option::is_none")]
1032-
#[validate(range(min = 1))]
1032+
#[validate(range(min = 0))]
10331033
pub max_payload_index_count: Option<usize>,
10341034
}
10351035

@@ -1171,9 +1171,9 @@ pub struct StrictModeConfigOutput {
11711171
#[serde(skip_serializing_if = "Option::is_none")]
11721172
pub sparse_config: Option<StrictModeSparseConfigOutput>,
11731173

1174-
/// Max number of payload index in a collection
1174+
/// Max number of payload indexes in a collection
11751175
#[serde(skip_serializing_if = "Option::is_none")]
1176-
#[validate(range(min = 1))]
1176+
#[validate(range(min = 0))]
11771177
pub max_payload_index_count: Option<usize>,
11781178
}
11791179

tests/openapi/test_strictmode.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2461,7 +2461,7 @@ def test_strict_mode_payload_index_count(collection_name):
24612461

24622462
assert not response.ok
24632463
assert response.status_code == 400
2464-
assert " Collection already has the maximum number of payload indices (1). Help: Please delete an existing index before creating a new one." in response.json()['status']['error']
2464+
assert "Collection already has the maximum number of payload indices (1). Help: Please delete an existing index before creating a new one." in response.json()['status']['error']
24652465

24662466
# let's increase the limit by one
24672467
set_strict_mode(collection_name, {
@@ -2499,7 +2499,7 @@ def test_strict_mode_payload_index_count(collection_name):
24992499

25002500
assert not response.ok
25012501
assert response.status_code == 400
2502-
assert " Collection already has the maximum number of payload indices (2). Help: Please delete an existing index before creating a new one." in response.json()['status']['error']
2502+
assert "Collection already has the maximum number of payload indices (2). Help: Please delete an existing index before creating a new one." in response.json()['status']['error']
25032503

25042504
set_strict_mode(collection_name, {
25052505
"enabled": False,

0 commit comments

Comments
 (0)