Skip to content

Commit 3f444fa

Browse files
Feature/ft create sortable (#533)
* Add SORTABLE option to FT.CREATE and ignore it Signed-off-by: Alexandru Filip <[email protected]> * Add tests Signed-off-by: Alexandru Filip <[email protected]> * Fix flaky test (#530) * Fix flaky test Signed-off-by: Allen Samuels <[email protected]> * Fix CME too Signed-off-by: Allen Samuels <[email protected]> --------- Signed-off-by: Allen Samuels <[email protected]> --------- Signed-off-by: Alexandru Filip <[email protected]> Signed-off-by: Allen Samuels <[email protected]> Co-authored-by: Allen Samuels <[email protected]>
1 parent 3faeb67 commit 3f444fa

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

COMMANDS.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ FT.CREATE <index-name>
2525
<field-identifier> [AS <field-alias>]
2626
NUMERIC
2727
| TAG [SEPARATOR <sep>] [CASESENSITIVE]
28-
| VECTOR [HNSW | FLAT] <attr_count> [<attribute_name> <attribute_value>]+)
28+
| VECTOR [HNSW | FLAT] <attr_count> [<attribute_name> <attribute_value>]+
29+
[SORTABLE]
2930
)+
3031
```
3132
@@ -61,6 +62,10 @@ FT.CREATE <index-name>
6162
- **EF\_CONSTRUCTION \<number\>** (optional): controls the number of vectors examined during index construction. Higher values for this parameter will improve recall ratio at the expense of longer index creation times. The default value is 200\. Maximum value is 4096\.
6263
- **EF\_RUNTIME \<number\>** (optional): controls the number of vectors to be examined during a query operation. The default is 10, and the max is 4096\. You can set this parameter value for each query you run. Higher values increase query times, but improve query recall.
6364
65+
### Field options
66+
67+
**SORTABLE**: This parameter is currently ignored as all field types are considered to be sortable
68+
6469
**RESPONSE** OK or error.
6570
6671
## FT.DROPINDEX

src/commands/ft_create_parser.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,18 @@ absl::StatusOr<data_model::Attribute *> ParseAttributeArgs(
404404
} else {
405405
CHECK(false);
406406
}
407+
408+
// Check for SORTABLE option and ignore it
409+
if (itr.DistanceEnd() > 0) {
410+
auto next_arg = itr.Get();
411+
if (next_arg.ok()) {
412+
absl::string_view order_str = vmsdk::ToStringView(next_arg.value());
413+
if (absl::EqualsIgnoreCase(order_str, "SORTABLE")) {
414+
itr.Next();
415+
}
416+
}
417+
}
418+
407419
attribute_proto->set_allocated_index(index_proto.release());
408420
return attribute_proto;
409421
}

testing/ft_create_test.cc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,26 @@ INSTANTIATE_TEST_SUITE_P(
188188
},
189189
},
190190
},
191+
{
192+
.test_name = "happy_path_sortable",
193+
.argv = {"FT.CREATE", "test_index_schema", "schema", "field1",
194+
"numeric", "SORTABLE", "field2", "tag", "separator", "|",
195+
"sortable"},
196+
.index_schema_name = "test_index_schema",
197+
.expected_run_return = VALKEYMODULE_OK,
198+
.expected_reply_message = "+OK\r\n",
199+
.expected_indexes =
200+
{
201+
{
202+
.attribute_alias = "field1",
203+
.indexer_type = indexes::IndexerType::kNumeric,
204+
},
205+
{
206+
.attribute_alias = "field2",
207+
.indexer_type = indexes::IndexerType::kTag,
208+
},
209+
},
210+
},
191211
}),
192212
[](const TestParamInfo<FTCreateTestCase>& info) {
193213
return info.param.test_name;

0 commit comments

Comments
 (0)