Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 5 additions & 5 deletions integration/test_query_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_query_string_depth_limit(self):
"""
client: Valkey = self.server.get_new_client()
# Test that the default query string limit is 1000
assert client.execute_command("CONFIG GET search.query-string-depth") == [b"search.query-string-depth", b"1000"]
assert client.execute_command("CONFIG GET search.query-string-depth") == [b"search.query-string-depth", b"16"]
# Test that we can set the query string limit to 1
assert client.execute_command("CONFIG SET search.query-string-depth 1") == b"OK"
assert client.execute_command("FT.CREATE my_index ON HASH PREFIX 1 doc: SCHEMA price NUMERIC category TAG SEPARATOR | doc_embedding VECTOR FLAT 6 TYPE FLOAT32 DIM 128 DISTANCE_METRIC COSINE") == b"OK"
Expand Down Expand Up @@ -83,17 +83,17 @@ def test_query_string_depth_limit(self):
assert False
except ResponseError as e:
assert str(e) == "Invalid filter expression: `((((((((((@price:[10 20]))))))))))`. Query string is too complex"
# Test that the config ranges from 1 to 4294967295
# Test that the config ranges from 1 to 16
try:
client.execute_command("CONFIG SET search.query-string-depth 0")
assert False
except ResponseError as e:
assert "argument must be between 1 and 4294967295 inclusive" in str(e)
assert "argument must be between 1 and 16 inclusive" in str(e)
try:
client.execute_command("CONFIG SET search.query-string-depth 4294967296")
client.execute_command("CONFIG SET search.query-string-depth 17")
assert False
except ResponseError as e:
assert "argument must be between 1 and 4294967295 inclusive" in str(e)
assert "argument must be between 1 and 16 inclusive" in str(e)

def test_query_string_terms_count_limit(self):
"""
Expand Down
8 changes: 4 additions & 4 deletions src/commands/filter_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ namespace options {
/// Register the "--query-string-depth" flag. Controls the depth of the query
/// string parsing from the FT.SEARCH cmd.
constexpr absl::string_view kQueryStringDepthConfig{"query-string-depth"};
constexpr uint32_t kDefaultQueryStringDepth{1000};
constexpr uint32_t kMaxQueryStringDepth{16};
constexpr uint32_t kMinimumQueryStringDepth{1};
static auto query_string_depth =
config::NumberBuilder(kQueryStringDepthConfig, // name
kDefaultQueryStringDepth, // default size
kMaxQueryStringDepth, // default size
kMinimumQueryStringDepth, // min size
UINT_MAX) // max size
.WithValidationCallback(CHECK_RANGE(kMinimumQueryStringDepth, UINT_MAX,
kMaxQueryStringDepth) // max size
.WithValidationCallback(CHECK_RANGE(kMinimumQueryStringDepth, kMaxQueryStringDepth,
kQueryStringDepthConfig))
.Build();

Expand Down
2 changes: 1 addition & 1 deletion src/commands/ft_create_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ constexpr int kDefaultTagFieldLenLimit{256};
constexpr int kDefaultNumericFieldLenLimit{128};
constexpr size_t kMaxAttributesCount{100};
constexpr int kMaxDimensionsCount{64000};
constexpr int kMaxM{2000000};
constexpr int kMaxM{256};
constexpr int kMaxEfConstruction{4096};
constexpr int kMaxEfRuntime{4096};
constexpr int kMaxPrefixesCount{16};
Expand Down
9 changes: 6 additions & 3 deletions src/valkey_search_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,16 @@ namespace config = vmsdk::config;
/// Register the "--query-string-bytes" flag. Controls the length of the query
/// string of the FT.SEARCH cmd.
constexpr absl::string_view kQueryStringBytesConfig{"query-string-bytes"};
constexpr uint32_t kDefaultQueryStringBytes{10240};
constexpr uint32_t kMaxQueryStringBytes{10240};
constexpr uint32_t kMinimumQueryStringBytes{1};
static auto query_string_bytes =
config::NumberBuilder(kQueryStringBytesConfig, // name
kDefaultQueryStringBytes, // default size
kMaxQueryStringBytes, // default size
kMinimumQueryStringBytes, // min size
UINT_MAX) // max size
kMaxQueryStringBytes) // max size
.WithValidationCallback(CHECK_RANGE(kMinimumQueryStringBytes,
kMaxQueryStringBytes,
kQueryStringBytesConfig))
.Build();

constexpr absl::string_view kHNSWBlockSizeConfig{"hnsw-block-size"};
Expand Down
4 changes: 2 additions & 2 deletions testing/ft_create_parser_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ INSTANTIATE_TEST_SUITE_P(
.expected_error_message =
"Invalid field type for field `hash_field1`: Invalid range: "
"Value below minimum; M must be a positive integer greater "
"than 0 and cannot exceed 2000000.",
"than 0 and cannot exceed 256.",
},
{
.test_name = "invalid_m_too_big",
Expand All @@ -664,7 +664,7 @@ INSTANTIATE_TEST_SUITE_P(
.expected_error_message =
"Invalid field type for field `hash_field1`: Invalid range: "
"Value above maximum; M must be a positive integer greater "
"than 0 and cannot exceed 2000000.",
"than 0 and cannot exceed 256.",
},
{
.test_name = "invalid_ef_construction_zero",
Expand Down